Boost.Hana: How to check if function has specialisation for a certain type?
I have a template function that has no definition by default but it specialised by some types: template <typename T> auto foo(bar &, const T &) -> void; template <> auto foo<std::string>(bar &, const std::string &) -> void {} How do I write a constexpr function that tells me if type T has a specialisation for the above function? My best effort: namespace detail { auto has_foo(hana::is_valid([](auto &b, const auto &t) -> decltype(foo(b, t)) {})); } // namespace detail template <typename T> constexpr auto has_foo() -> bool { using hana::type_c; return detail::has_foo(type_c<bar>, type_c<T>); }