• 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/adapt_struct.hpp>
6 #include <boost/hana/assert.hpp>
7 #include <boost/hana/concept/struct.hpp>
8 #include <boost/hana/contains.hpp>
9 #include <boost/hana/string.hpp>
10 
11 #include <laws/base.hpp>
12 namespace hana = boost::hana;
13 using hana::test::ct_eq;
14 
15 
16 namespace ns {
17     struct Data0 { };
18     struct Data1 {
19         ct_eq<1> member1;
20     };
21     struct Data2 {
22         ct_eq<1> member1;
23         ct_eq<2> member2;
24     };
25     struct Data3 {
26         ct_eq<1> member1;
27         ct_eq<2> member2;
28         ct_eq<3> member3;
29     };
30     struct MemberArray {
31         int array[10];
32     };
33 }
34 
35 BOOST_HANA_ADAPT_STRUCT(ns::Data0);
36 BOOST_HANA_ADAPT_STRUCT(ns::Data1, member1);
37 BOOST_HANA_ADAPT_STRUCT(ns::Data2, member1, member2);
38 BOOST_HANA_ADAPT_STRUCT(ns::Data3, member1, member2, member3);
39 BOOST_HANA_ADAPT_STRUCT(ns::MemberArray, array);
40 
41 static_assert(hana::Struct<ns::Data0>::value, "");
42 static_assert(hana::Struct<ns::Data1>::value, "");
43 static_assert(hana::Struct<ns::Data2>::value, "");
44 static_assert(hana::Struct<ns::Data3>::value, "");
45 static_assert(hana::Struct<ns::MemberArray>::value, "");
46 
main()47 int main() {
48     BOOST_HANA_CONSTANT_CHECK(hana::contains(ns::Data1{}, BOOST_HANA_STRING("member1")));
49 
50     BOOST_HANA_CONSTANT_CHECK(hana::contains(ns::Data2{}, BOOST_HANA_STRING("member1")));
51     BOOST_HANA_CONSTANT_CHECK(hana::contains(ns::Data2{}, BOOST_HANA_STRING("member2")));
52 
53     BOOST_HANA_CONSTANT_CHECK(hana::contains(ns::Data3{}, BOOST_HANA_STRING("member1")));
54     BOOST_HANA_CONSTANT_CHECK(hana::contains(ns::Data3{}, BOOST_HANA_STRING("member2")));
55     BOOST_HANA_CONSTANT_CHECK(hana::contains(ns::Data3{}, BOOST_HANA_STRING("member3")));
56 
57     BOOST_HANA_CONSTANT_CHECK(hana::contains(ns::MemberArray{}, BOOST_HANA_STRING("array")));
58 }
59