/* @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 #include #include #include #include using namespace boost::hana; namespace ns1 { //! [comparable] struct T; struct U; BOOST_HANA_CONSTANT_CHECK(type == type); BOOST_HANA_CONSTANT_CHECK(type != type); //! [comparable] } namespace ns2 { //! [largest] template using largest = decltype(maximum_by(less ^on^ sizeof_, tuple_t)); template struct storage { char s[size]; }; static_assert(std::is_same< largest, storage<2>, storage<3>>::type, storage<3> >{}, ""); //! [largest] } namespace ns3 { //! [decltype] struct X { }; BOOST_HANA_CONSTANT_CHECK(type == decltype_(X{})); BOOST_HANA_CONSTANT_CHECK(type == decltype_(1)); //! [decltype] } namespace ns4 { //! [sizeof] struct X { }; static_assert(sizeof_(type) == sizeof(X), ""); static_assert(sizeof_(type) == sizeof(int), ""); //! [sizeof] } namespace ns5 { //! [template] template struct f; struct x; struct y; BOOST_HANA_CONSTANT_CHECK(template_() == type>); BOOST_HANA_CONSTANT_CHECK(template_(type) == type>); BOOST_HANA_CONSTANT_CHECK(template_(type, type) == type>); static_assert(std::is_same< decltype(template_)::apply::type, f >::value, ""); //! [template] } namespace ns6 { //! [metafunction] template struct f { struct type; }; struct x; struct y; BOOST_HANA_CONSTANT_CHECK(metafunction() == type::type>); BOOST_HANA_CONSTANT_CHECK(metafunction(type) == type::type>); BOOST_HANA_CONSTANT_CHECK(metafunction(type, type) == type::type>); static_assert(std::is_same< decltype(metafunction)::apply::type, f::type >::value, ""); //! [metafunction] } namespace ns7 { //! [liftable_trait] BOOST_HANA_CONSTANT_CHECK(trait(type)); BOOST_HANA_CONSTANT_CHECK(not_(trait(type))); //! [liftable_trait] } namespace ns8 { //! [non_liftable_trait] BOOST_HANA_CONSTEXPR_LAMBDA auto extent = [](auto t, auto n) { return std::extent{}; }; BOOST_HANA_CONSTANT_CHECK(extent(type, int_<1>) == size_t<0>); BOOST_HANA_CONSTANT_CHECK(extent(type, int_<1>) == size_t<2>); //! [non_liftable_trait] } namespace ns9 { //! [trait_] BOOST_HANA_CONSTANT_CHECK(trait_(2)); BOOST_HANA_CONSTANT_CHECK(trait_(2ll)); BOOST_HANA_CONSTANT_CHECK(not_(trait_(2.2))); //! [trait_] } int main() { }