adl.cpp 777 B

123456789101112131415161718192021222324
  1. // Copyright Louis Dionne 2013-2017
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  4. #include <boost/hana/type.hpp>
  5. namespace hana = boost::hana;
  6. template <bool b = false>
  7. struct invalid { static_assert(b, "invalid must not be instantiated"); };
  8. template <typename T> void adl(T) { }
  9. template <typename T> void adl_pattern(hana::basic_type<T>) { }
  10. int main() {
  11. // ADL kicks in but `invalid<>` must not instantiated
  12. adl(hana::type_c<invalid<>>);
  13. adl_pattern(hana::type_c<invalid<>>);
  14. // ADL instantiates the types recursively, make sure that works too
  15. adl(hana::typeid_(hana::type_c<invalid<>>));
  16. adl_pattern(hana::typeid_(hana::type_c<invalid<>>));
  17. }