/* @copyright Louis Dionne 2014 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #include #include namespace hana = boost::hana; ////////////////////////////////////////////////////////////////////////////// // Type class ////////////////////////////////////////////////////////////////////////////// template struct Typeclass; namespace boost { namespace hana { template <> struct instance { template struct with { static constexpr bool has_complimentary = false; static constexpr bool has_defaults = false; static constexpr bool has_predicated_defaults = false; }; }; template <> struct defaults { template struct with : defaults<> { static constexpr bool has_complimentary = false; static constexpr bool has_defaults = true; static constexpr bool has_predicated_defaults = false; }; }; }} template struct Typeclass : hana::instance::template with { }; ////////////////////////////////////////////////////////////////////////////// // Predicated defaults ////////////////////////////////////////////////////////////////////////////// template struct predicate : std::false_type { }; namespace boost { namespace hana { template struct defaults::with{}>> : defaults<> { static constexpr bool has_complimentary = false; static constexpr bool has_defaults = false; static constexpr bool has_predicated_defaults = true; }; }} ////////////////////////////////////////////////////////////////////////////// // Data types ////////////////////////////////////////////////////////////////////////////// struct PredicatedDefaults; struct NoPredicatedDefaults; struct SomethingElse; template <> struct predicate : std::true_type { }; template <> struct Typeclass : hana::defaults::with { }; template <> struct Typeclass : hana::defaults::with { }; int main() { static_assert(!Typeclass::has_complimentary, ""); static_assert(!Typeclass::has_defaults, ""); static_assert(Typeclass::has_predicated_defaults, ""); static_assert(!Typeclass::has_complimentary, ""); static_assert(Typeclass::has_defaults, ""); static_assert(!Typeclass::has_predicated_defaults, ""); static_assert(!Typeclass::has_complimentary, ""); static_assert(!Typeclass::has_defaults, ""); static_assert(!Typeclass::has_predicated_defaults, ""); }