// Copyright Louis Dionne 2013-2016 // 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 tag is detected properly ////////////////////////////////////////////////////////////////////////// { static_assert(std::is_same< tag_of_t, ext::std::integral_constant_tag >{}, ""); static_assert(std::is_same< tag_of_t, ext::std::integral_constant_tag >{}, ""); static_assert(std::is_same< tag_of_t>, ext::std::integral_constant_tag >{}, ""); static_assert(!std::is_same< tag_of_t, ext::std::integral_constant_tag >{}, ""); static_assert(!std::is_same< tag_of_t, ext::std::integral_constant_tag >{}, ""); static_assert(!std::is_same< tag_of_t, ext::std::integral_constant_tag >{}, ""); static_assert(!std::is_same< tag_of_t, ext::std::integral_constant_tag >{}, ""); } ////////////////////////////////////////////////////////////////////////// // Interoperation with hana::integral_constant ////////////////////////////////////////////////////////////////////////// { BOOST_HANA_CONSTANT_CHECK(std::integral_constant{} == int_c<1>); BOOST_HANA_CONSTANT_CHECK(std::integral_constant{} == long_c<1>); BOOST_HANA_CONSTANT_CHECK(std::integral_constant{} != int_c<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 ////////////////////////////////////////////////////////////////////////// // Monoid, Group, Ring, EuclideanRing ////////////////////////////////////////////////////////////////////////// { test::TestMonoid>{ints}; test::TestGroup>{ints}; test::TestRing>{ints}; test::TestEuclideanRing>{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 and Hashable ////////////////////////////////////////////////////////////////////////// test::TestComparable>{ints}; test::TestHashable>{ints}; #elif BOOST_HANA_TEST_PART == 6 ////////////////////////////////////////////////////////////////////////// // Orderable ////////////////////////////////////////////////////////////////////////// test::TestOrderable>{ints}; #endif }