• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/detail/canonical_constant.hpp>
6 #include <boost/hana/tuple.hpp>
7 
8 #include <laws/comparable.hpp>
9 #include <laws/constant.hpp>
10 #include <laws/euclidean_ring.hpp>
11 #include <laws/group.hpp>
12 #include <laws/logical.hpp>
13 #include <laws/monoid.hpp>
14 #include <laws/orderable.hpp>
15 #include <laws/ring.hpp>
16 namespace hana = boost::hana;
17 
18 
19 template <typename T, T v>
20 struct canonical {
21     static constexpr T value = v;
22     using hana_tag = hana::detail::CanonicalConstant<T>;
23 };
24 
main()25 int main() {
26     auto ints = hana::make_tuple(
27         canonical<int, -10>{}, canonical<int, -2>{}, canonical<int, 0>{},
28         canonical<int, 1>{}, canonical<int, 3>{}, canonical<int, 4>{}
29     );
30 
31     auto bools = hana::make_tuple(canonical<bool, true>{}, canonical<bool, false>{});
32 
33     // Constant
34     hana::test::TestConstant<hana::detail::CanonicalConstant<int>>{ints, hana::tuple_t<int, long, long long>};
35     hana::test::TestConstant<hana::detail::CanonicalConstant<bool>>{bools, hana::tuple_t<bool>};
36 
37     // Monoid, Group, Ring, EuclideanRing
38     hana::test::TestMonoid<hana::detail::CanonicalConstant<int>>{ints};
39     hana::test::TestGroup<hana::detail::CanonicalConstant<int>>{ints};
40     hana::test::TestRing<hana::detail::CanonicalConstant<int>>{ints};
41     hana::test::TestEuclideanRing<hana::detail::CanonicalConstant<int>>{ints};
42 
43     // Logical
44     {
45         auto ints = hana::make_tuple(
46             canonical<int, -2>{}, canonical<int, 0>{},
47             canonical<int, 1>{}, canonical<int, 3>{}
48         );
49         hana::test::TestLogical<hana::detail::CanonicalConstant<int>>{ints};
50         hana::test::TestLogical<hana::detail::CanonicalConstant<bool>>{bools};
51     }
52 
53     // Comparable and Orderable
54     hana::test::TestComparable<hana::detail::CanonicalConstant<int>>{ints};
55     hana::test::TestOrderable<hana::detail::CanonicalConstant<int>>{ints};
56 }
57