]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/detail/algorithm.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/detail/algorithm.hpp>
6 #include <boost/hana/equal.hpp>
7 #include <boost/hana/less.hpp>
8 #include <boost/hana/mult.hpp>
9 namespace hana
= boost::hana
;
12 // The algorithms are taken from the suggested implementations on cppreference.
13 // Hence, we assume them to be correct and we only make sure they compile, to
14 // avoid stupid mistakes I could have made when copy/pasting and editing.
16 // Oh, and we also make sure they can be used in a constexpr context.
17 constexpr bool constexpr_context() {
19 hana::detail::constexpr_swap(x
, y
);
21 int array
[6] = {1, 2, 3, 4, 5, 6};
23 int* last
= array
+ 6;
25 hana::detail::reverse(first
, last
);
27 hana::detail::next_permutation(first
, last
, hana::less
);
28 hana::detail::next_permutation(first
, last
);
30 hana::detail::lexicographical_compare(first
, last
, first
, last
, hana::less
);
31 hana::detail::lexicographical_compare(first
, last
, first
, last
);
33 hana::detail::equal(first
, last
, first
, last
, hana::equal
);
34 hana::detail::equal(first
, last
, first
, last
);
36 hana::detail::sort(first
, last
, hana::equal
);
37 hana::detail::sort(first
, last
);
39 hana::detail::find(first
, last
, 3);
40 hana::detail::find_if(first
, last
, hana::equal
.to(3));
42 hana::detail::iota(first
, last
, 0);
44 hana::detail::count(first
, last
, 2);
46 hana::detail::accumulate(first
, last
, 0);
47 hana::detail::accumulate(first
, last
, 1, hana::mult
);
49 hana::detail::min_element(first
, last
);
54 static_assert(constexpr_context(), "");