1 // Copyright Louis Dionne 2013-2017 2 // Distributed under the Boost Software License, Version 1.0. 3 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) 4 5 #include <boost/hana/assert.hpp> 6 #include <boost/hana/core/to.hpp> 7 #include <boost/hana/equal.hpp> 8 #include <boost/hana/for_each.hpp> 9 #include <boost/hana/not.hpp> 10 #include <boost/hana/not_equal.hpp> // for operator != 11 #include <boost/hana/permutations.hpp> 12 #include <boost/hana/set.hpp> 13 #include <boost/hana/tuple.hpp> 14 15 #include <laws/base.hpp> 16 namespace hana = boost::hana; 17 using hana::test::ct_eq; 18 19 main()20int main() { 21 auto check = [](auto ...keys) { 22 auto keys_set = hana::make_set(keys...); 23 auto keys_tuple = hana::make_tuple(keys...); 24 auto possible_arrangements = hana::permutations(keys_tuple); 25 26 hana::for_each(possible_arrangements, [&](auto perm) { 27 BOOST_HANA_CONSTANT_CHECK(hana::equal( 28 hana::to_set(perm), 29 keys_set 30 )); 31 }); 32 33 BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( 34 keys_set, 35 hana::make_set(keys..., ct_eq<999>{}) 36 ))); 37 }; 38 39 check(); 40 check(ct_eq<0>{}); 41 check(ct_eq<0>{}, ct_eq<1>{}); 42 check(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); 43 44 // check operators 45 BOOST_HANA_CONSTANT_CHECK( 46 hana::make_set(ct_eq<0>{}) 47 == 48 hana::make_set(ct_eq<0>{}) 49 ); 50 51 BOOST_HANA_CONSTANT_CHECK( 52 hana::make_set(ct_eq<0>{}) 53 != 54 hana::make_set(ct_eq<1>{}) 55 ); 56 } 57