/* @copyright Louis Dionne 2015 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 #include #include #include #include #include #include #include #include using namespace boost::hana; struct inherit_simple : std::integral_constant { }; struct inherit_no_default : std::integral_constant { inherit_no_default() = delete; }; struct incomplete; struct empty_type { }; struct non_pod { virtual ~non_pod() { } }; int main() { auto ints = make( std::integral_constant{}, std::integral_constant{}, std::integral_constant{}, std::integral_constant{}, std::integral_constant{} ); (void)ints; #if BOOST_HANA_TEST_PART == 1 ////////////////////////////////////////////////////////////////////////// // Make sure the data type is detected properly ////////////////////////////////////////////////////////////////////////// { static_assert(std::is_same< datatype_t, ext::std::IntegralConstant >{}, ""); static_assert(std::is_same< datatype_t, ext::std::IntegralConstant >{}, ""); static_assert(std::is_same< datatype_t>, ext::std::IntegralConstant >{}, ""); static_assert(!std::is_same< datatype_t, ext::std::IntegralConstant >{}, ""); static_assert(!std::is_same< datatype_t, ext::std::IntegralConstant >{}, ""); static_assert(!std::is_same< datatype_t, ext::std::IntegralConstant >{}, ""); static_assert(!std::is_same< datatype_t, ext::std::IntegralConstant >{}, ""); } ////////////////////////////////////////////////////////////////////////// // Interoperation with IntegralConstant ////////////////////////////////////////////////////////////////////////// { BOOST_HANA_CONSTANT_CHECK(std::integral_constant{} == int_<1>); BOOST_HANA_CONSTANT_CHECK(std::integral_constant{} == long_<1>); BOOST_HANA_CONSTANT_CHECK(std::integral_constant{} != int_<3>); } #elif BOOST_HANA_TEST_PART == 2 ////////////////////////////////////////////////////////////////////////// // Constant ////////////////////////////////////////////////////////////////////////// { // value static_assert(value(std::integral_constant{}) == 0, ""); static_assert(value(std::integral_constant{}) == 1, ""); static_assert(value(std::integral_constant{}) == 3, ""); // laws test::TestConstant>{ints, tuple_t}; } #elif BOOST_HANA_TEST_PART == 3 ////////////////////////////////////////////////////////////////////////// // Enumerable, Monoid, Group, Ring, IntegralDomain ////////////////////////////////////////////////////////////////////////// { test::TestEnumerable>{ints}; test::TestMonoid>{ints}; test::TestGroup>{ints}; test::TestRing>{ints}; test::TestIntegralDomain>{ints}; } #elif BOOST_HANA_TEST_PART == 4 ////////////////////////////////////////////////////////////////////////// // Logical ////////////////////////////////////////////////////////////////////////// { auto t = test::ct_eq<3>{}; auto e = test::ct_eq<4>{}; // eval_if { BOOST_HANA_CONSTANT_CHECK(equal( eval_if(std::true_type{}, always(t), always(e)), t )); BOOST_HANA_CONSTANT_CHECK(equal( eval_if(std::false_type{}, always(t), always(e)), e )); } // not_ { BOOST_HANA_CONSTANT_CHECK(equal( not_(std::true_type{}), std::false_type{} )); BOOST_HANA_CONSTANT_CHECK(equal( not_(std::false_type{}), std::true_type{} )); } auto ints = make( std::integral_constant{}, std::integral_constant{}, std::integral_constant{}, std::integral_constant{} ); auto bools = make(std::true_type{}, std::false_type{}); // laws test::TestLogical>{ints}; test::TestLogical>{bools}; } #elif BOOST_HANA_TEST_PART == 5 ////////////////////////////////////////////////////////////////////////// // Comparable ////////////////////////////////////////////////////////////////////////// test::TestComparable>{ints}; #elif BOOST_HANA_TEST_PART == 6 ////////////////////////////////////////////////////////////////////////// // Orderable ////////////////////////////////////////////////////////////////////////// test::TestOrderable>{ints}; #endif }