Imported Upstream version 1.64.0
[platform/upstream/boost.git] / libs / hana / test / concept / struct / keys.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/concept/struct.hpp>
7 #include <boost/hana/equal.hpp>
8 #include <boost/hana/integral_constant.hpp>
9 #include <boost/hana/keys.hpp>
10
11 #include "minimal_struct.hpp"
12 #include <laws/base.hpp>
13 #include <support/seq.hpp>
14 namespace hana = boost::hana;
15 using hana::test::ct_eq;
16
17
18 template <int i = 0>
19 struct undefined { };
20
21 int main() {
22     BOOST_HANA_CONSTANT_CHECK(hana::equal(
23         hana::keys(obj()),
24         ::seq()
25     ));
26
27     BOOST_HANA_CONSTANT_CHECK(hana::equal(
28         hana::keys(obj(undefined<0>{})),
29         ::seq(hana::int_c<0>)
30     ));
31
32     BOOST_HANA_CONSTANT_CHECK(hana::equal(
33         hana::keys(obj(undefined<0>{}, undefined<1>{})),
34         ::seq(hana::int_c<0>, hana::int_c<1>)
35     ));
36
37     BOOST_HANA_CONSTANT_CHECK(hana::equal(
38         hana::keys(obj(undefined<0>{}, undefined<1>{}, undefined<2>{})),
39         ::seq(hana::int_c<0>, hana::int_c<1>, hana::int_c<2>)
40     ));
41
42     BOOST_HANA_CONSTANT_CHECK(hana::equal(
43         hana::keys(obj(undefined<0>{}, undefined<1>{}, undefined<2>{}, undefined<3>{})),
44         ::seq(hana::int_c<0>, hana::int_c<1>, hana::int_c<2>, hana::int_c<3>)
45     ));
46 }