2
0
mirror of https://github.com/boostorg/hana.git synced 2026-02-10 11:32:26 +00:00

Core: make default_instance dependent on the type class arguments

This commit is contained in:
Louis Dionne
2014-07-13 22:38:52 -04:00
parent 49d9b40fc1
commit a5cab82de8
4 changed files with 72 additions and 69 deletions

View File

@@ -16,21 +16,19 @@ namespace hana = boost::hana;
struct Showable {
BOOST_HANA_TYPECLASS(Showable);
struct mcd { };
template <typename T>
struct default_instance : mcd {
template <typename X>
static std::string show_impl(X)
{ return "<?>"; }
};
};
BOOST_HANA_CONSTEXPR_LAMBDA auto show = [](auto x) {
return Showable::instance<hana::datatype_t<decltype(x)>>::show_impl(x);
};
namespace boost { namespace hana {
template <>
struct default_instance<Showable> : Showable::mcd {
template <typename X>
static std::string show_impl(X)
{ return "<?>"; }
};
}}
template <>
struct Showable::instance<int> : Showable::mcd {
static auto show_impl(int i)