]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/builtin_array.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)
5 #include <boost/hana/any_of.hpp>
6 #include <boost/hana/assert.hpp>
7 #include <boost/hana/bool.hpp>
8 #include <boost/hana/concept/foldable.hpp>
9 #include <boost/hana/concept/searchable.hpp>
10 #include <boost/hana/equal.hpp>
11 #include <boost/hana/find_if.hpp>
12 #include <boost/hana/functional/always.hpp>
13 #include <boost/hana/functional/placeholder.hpp>
14 #include <boost/hana/not.hpp>
15 #include <boost/hana/optional.hpp>
16 #include <boost/hana/unpack.hpp>
18 #include <laws/base.hpp>
19 #include <laws/foldable.hpp>
20 #include <laws/searchable.hpp>
23 namespace hana
= boost::hana
;
26 template <typename T
, std::size_t n
>
30 // We can't check the laws because builtin arrays can't be passed
33 //////////////////////////////////////////////////////////////////////////
35 //////////////////////////////////////////////////////////////////////////
40 int d
[] = {1, 2, 3, 4};
44 hana::test::_injection
<0> f
{};
46 BOOST_HANA_RUNTIME_CHECK(hana::equal(
51 BOOST_HANA_RUNTIME_CHECK(hana::equal(
56 BOOST_HANA_RUNTIME_CHECK(hana::equal(
61 BOOST_HANA_RUNTIME_CHECK(hana::equal(
67 static_assert(hana::Foldable
<int[3]>::value
, "");
70 //////////////////////////////////////////////////////////////////////////
72 //////////////////////////////////////////////////////////////////////////
77 hana::not_(hana::any_of(array
<int, 1>{0}, hana::equal
.to(1)))
81 hana::any_of(array
<int, 2>{0, 1}, hana::equal
.to(0))
84 hana::any_of(array
<int, 2>{0, 1}, hana::equal
.to(1))
87 hana::not_(hana::any_of(array
<int, 2>{0, 1}, hana::equal
.to(2)))
91 hana::any_of(array
<int, 3>{0, 1, 2}, hana::equal
.to(0))
94 hana::any_of(array
<int, 3>{0, 1, 2}, hana::equal
.to(1))
97 hana::any_of(array
<int, 3>{0, 1, 2}, hana::equal
.to(2))
100 hana::not_(hana::any_of(array
<int, 3>{0, 1, 2}, hana::equal
.to(3)))
105 // Note: Because we need the predicate to return a Constant, this
106 // is incredibly not powerful.
108 static_assert(hana::equal(
109 hana::find_if(array
<int, 1>{0}, hana::always(hana::true_c
)),
113 BOOST_HANA_CONSTANT_CHECK(hana::equal(
114 hana::find_if(array
<int, 1>{0}, hana::always(hana::false_c
)),
119 static_assert(hana::Searchable
<int[3]>::value
, "");