1// Copyright Louis Dionne 2013-2022
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/contains.hpp>
7#include <boost/hana/experimental/types.hpp>
8#include <boost/hana/not.hpp>
9#include <boost/hana/type.hpp>
10namespace hana = boost::hana;
11
12
13template <int> struct x;
14struct undefined { };
15
16int main() {
17 BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains(
18 hana::experimental::types<>{},
19 undefined{}
20 )));
21
22 BOOST_HANA_CONSTANT_CHECK(hana::contains(
23 hana::experimental::types<x<0>>{},
24 hana::type_c<x<0>>
25 ));
26 BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains(
27 hana::experimental::types<x<0>>{},
28 hana::type_c<x<999>>
29 )));
30
31 BOOST_HANA_CONSTANT_CHECK(hana::contains(
32 hana::experimental::types<x<0>, x<1>>{},
33 hana::type_c<x<0>>
34 ));
35 BOOST_HANA_CONSTANT_CHECK(hana::contains(
36 hana::experimental::types<x<0>, x<1>>{},
37 hana::type_c<x<1>>
38 ));
39 BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains(
40 hana::experimental::types<x<0>, x<1>>{},
41 hana::type_c<x<999>>
42 )));
43
44 BOOST_HANA_CONSTANT_CHECK(hana::contains(
45 hana::experimental::types<x<0>, x<1>, x<2>>{},
46 hana::type_c<x<0>>
47 ));
48 BOOST_HANA_CONSTANT_CHECK(hana::contains(
49 hana::experimental::types<x<0>, x<1>, x<2>>{},
50 hana::type_c<x<1>>
51 ));
52 BOOST_HANA_CONSTANT_CHECK(hana::contains(
53 hana::experimental::types<x<0>, x<1>, x<2>>{},
54 hana::type_c<x<2>>
55 ));
56 BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains(
57 hana::experimental::types<x<0>, x<1>, x<2>>{},
58 hana::type_c<x<999>>
59 )));
60
61 BOOST_HANA_CONSTANT_CHECK(hana::contains(
62 hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{},
63 hana::type_c<x<0>>
64 ));
65 BOOST_HANA_CONSTANT_CHECK(hana::contains(
66 hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{},
67 hana::type_c<x<1>>
68 ));
69 BOOST_HANA_CONSTANT_CHECK(hana::contains(
70 hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{},
71 hana::type_c<x<2>>
72 ));
73 BOOST_HANA_CONSTANT_CHECK(hana::contains(
74 hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{},
75 hana::type_c<x<3>>
76 ));
77 BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains(
78 hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{},
79 hana::type_c<x<999>>
80 )));
81}
82

source code of boost/libs/hana/test/experimental/types/contains.cpp