]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/detail/first_unsatisfied_index.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / hana / test / detail / first_unsatisfied_index.cpp
1 // Copyright Louis Dionne 2013-2016
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/detail/first_unsatisfied_index.hpp>
6
7 #include <boost/hana/not_equal.hpp>
8 #include <laws/base.hpp>
9
10 #include <type_traits>
11 namespace hana = boost::hana;
12 using hana::test::ct_eq;
13
14
15 struct poison {
16 poison() = default;
17 poison(poison const&) = delete;
18 };
19
20 int main() {
21 auto predicate = [](auto x) {
22 static_assert(!std::is_same<poison, decltype(x)>::value, "");
23 return hana::not_equal(x, ct_eq<9>{});
24 };
25
26 using Find = hana::detail::first_unsatisfied_index<decltype(predicate)>;
27
28 static_assert(decltype(Find{}())::value == 0, "");
29
30 static_assert(decltype(Find{}(ct_eq<9>{}))::value == 0, "");
31 static_assert(decltype(Find{}(ct_eq<0>{}))::value == 1, "");
32
33 static_assert(decltype(Find{}(ct_eq<9>{}, poison{}))::value == 0, "");
34 static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<9>{}))::value == 1, "");
35 static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<1>{}))::value == 2, "");
36
37 static_assert(decltype(Find{}(ct_eq<9>{}, poison{}, poison{}))::value == 0, "");
38 static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<9>{}, poison{}))::value == 1, "");
39 static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<1>{}, ct_eq<9>{}))::value == 2, "");
40 static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}))::value == 3, "");
41
42 static_assert(decltype(Find{}(ct_eq<9>{}, poison{}, poison{}, poison{}))::value == 0, "");
43 static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<9>{}, poison{}, poison{}))::value == 1, "");
44 static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<1>{}, ct_eq<9>{}, poison{}))::value == 2, "");
45 static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<9>{}))::value == 3, "");
46 static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}))::value == 4, "");
47 }