• 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/tuple.hpp>
6 #include <boost/hana/first.hpp>
7 #include <boost/hana/second.hpp>
8 
9 #include <laws/base.hpp>
10 #include <laws/comparable.hpp>
11 #include <laws/foldable.hpp>
12 #include <laws/orderable.hpp>
13 #include <laws/product.hpp>
14 #include <support/minimal_product.hpp>
15 #include <support/tracked.hpp>
16 
17 #include <utility>
18 namespace hana = boost::hana;
19 using hana::test::ct_eq;
20 using hana::test::ct_ord;
21 
22 
main()23 int main() {
24     // Make sure `first` and `second` are "accessors". If they are not,
25     // `Tracked` should report a double-move.
26     {
27         auto prod = ::minimal_product(::Tracked{1}, ::Tracked{2});
28         auto fst = hana::first(std::move(prod));
29         auto snd = hana::second(std::move(prod));
30     }
31 
32     //////////////////////////////////////////////////////////////////////////
33     // Comparable, Orderable, Foldable, Product
34     //////////////////////////////////////////////////////////////////////////
35     auto eq_elems = hana::make_tuple(ct_eq<3>{}, ct_eq<4>{});
36 
37     auto eqs = hana::make_tuple(
38           ::minimal_product(ct_eq<3>{}, ct_eq<3>{})
39         , ::minimal_product(ct_eq<3>{}, ct_eq<4>{})
40         , ::minimal_product(ct_eq<4>{}, ct_eq<3>{})
41         , ::minimal_product(ct_eq<4>{}, ct_eq<4>{})
42     );
43 
44     auto ords = hana::make_tuple(
45           ::minimal_product(ct_ord<3>{}, ct_ord<3>{})
46         , ::minimal_product(ct_ord<3>{}, ct_ord<4>{})
47         , ::minimal_product(ct_ord<4>{}, ct_ord<3>{})
48         , ::minimal_product(ct_ord<4>{}, ct_ord<4>{})
49     );
50 
51     hana::test::TestComparable<::MinimalProduct>{eqs};
52     hana::test::TestOrderable<::MinimalProduct>{ords};
53     hana::test::TestFoldable<::MinimalProduct>{eqs};
54     hana::test::TestProduct<::MinimalProduct>{eq_elems};
55 }
56