/* @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 #include #include namespace hana = boost::hana; template struct Incrementable; BOOST_HANA_CONSTEXPR_LAMBDA auto next = [](auto x) { return Incrementable>::next_impl(x); }; namespace boost { namespace hana { template <> struct instance { template struct with { }; }; template <> struct defaults { template struct with { }; }; }} template struct Incrementable : hana::instance::template with { }; namespace boost { namespace hana { template struct instance::with{} || std::is_floating_point{}> > : defaults::template with { template static constexpr auto next_impl(X x) { return x + 1; } }; }} int main() { BOOST_HANA_STATIC_ASSERT(next(1) == 2); BOOST_HANA_STATIC_ASSERT(next(3.3) == 4.3); BOOST_HANA_STATIC_ASSERT(next('a') == 'b'); }