Imported Upstream version 1.64.0
[platform/upstream/boost.git] / libs / hana / test / optional / concat.cpp
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/concat.hpp>
7 #include <boost/hana/equal.hpp>
8 #include <boost/hana/optional.hpp>
9
10 #include <laws/base.hpp>
11 namespace hana = boost::hana;
12 using hana::test::ct_eq;
13
14
15 int main() {
16     auto rv_nothing = [] { return hana::nothing; }; // rvalue nothing
17
18     BOOST_HANA_CONSTANT_CHECK(hana::equal(
19         hana::concat(rv_nothing(), hana::nothing),
20         hana::nothing
21     ));
22     BOOST_HANA_CONSTANT_CHECK(hana::equal(
23         hana::concat(hana::nothing, rv_nothing()),
24         hana::nothing
25     ));
26     BOOST_HANA_CONSTANT_CHECK(hana::equal(
27         hana::concat(rv_nothing(), rv_nothing()),
28         hana::nothing
29     ));
30     BOOST_HANA_CONSTANT_CHECK(hana::equal(
31         hana::concat(rv_nothing(), hana::just(ct_eq<0>{})),
32         hana::just(ct_eq<0>{})
33     ));
34     BOOST_HANA_CONSTANT_CHECK(hana::equal(
35         hana::concat(hana::just(ct_eq<0>{}), rv_nothing()),
36         hana::just(ct_eq<0>{})
37     ));
38
39     BOOST_HANA_CONSTANT_CHECK(hana::equal(
40         hana::concat(hana::nothing, hana::nothing),
41         hana::nothing
42     ));
43     BOOST_HANA_CONSTANT_CHECK(hana::equal(
44         hana::concat(hana::nothing, hana::just(ct_eq<0>{})),
45         hana::just(ct_eq<0>{})
46     ));
47     BOOST_HANA_CONSTANT_CHECK(hana::equal(
48         hana::concat(hana::just(ct_eq<0>{}), hana::nothing),
49         hana::just(ct_eq<0>{})
50     ));
51     BOOST_HANA_CONSTANT_CHECK(hana::equal(
52         hana::concat(hana::just(ct_eq<0>{}), hana::just(ct_eq<1>{})),
53         hana::just(ct_eq<0>{})
54     ));
55 }