summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/hana/example/is_disjoint.cpp
blob: 71cde04e51c17a4ab8564a95459ee5385878d175 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright Louis Dionne 2013-2017
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)

#include <boost/hana/assert.hpp>
#include <boost/hana/is_disjoint.hpp>
#include <boost/hana/map.hpp>
#include <boost/hana/not.hpp>
#include <boost/hana/set.hpp>
#include <boost/hana/tuple.hpp>
#include <boost/hana/type.hpp>

#include <string>
namespace hana = boost::hana;
using namespace std::literals;


int main() {
    // Tuples
    auto xs = hana::make_tuple(hana::int_c<1>, "alfa"s, hana::type_c<int>);
    auto ys = hana::make_tuple(hana::type_c<void>, hana::int_c<3>, "bravo"s);
    BOOST_HANA_RUNTIME_CHECK(hana::is_disjoint(xs, ys));

    // Sets
    auto s1 = hana::make_set(hana::int_c<1>, hana::type_c<void>, hana::int_c<2>);
    auto s2 = hana::make_set(hana::type_c<char>, hana::type_c<int>, hana::int_c<1>);
    BOOST_HANA_CONSTANT_CHECK(!hana::is_disjoint(s1, s2));

    // Maps
    auto vowels = hana::make_map(
        hana::make_pair(hana::char_c<'a'>, "alfa"s),
        hana::make_pair(hana::char_c<'e'>, "echo"s),
        hana::make_pair(hana::char_c<'i'>, "india"s)
        // ...
    );

    auto consonants = hana::make_map(
        hana::make_pair(hana::char_c<'b'>, "bravo"s),
        hana::make_pair(hana::char_c<'c'>, "charlie"s),
        hana::make_pair(hana::char_c<'f'>, "foxtrot"s)
        // ...
    );

    BOOST_HANA_CONSTANT_CHECK(hana::is_disjoint(vowels, consonants));
}