]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/test/detail/algorithm.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / test / detail / algorithm.cpp
CommitLineData
b32b8144 1// Copyright Louis Dionne 2013-2017
7c673cae
FG
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/algorithm.hpp>
6#include <boost/hana/equal.hpp>
7#include <boost/hana/less.hpp>
8#include <boost/hana/mult.hpp>
9namespace hana = boost::hana;
10
11
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.
15//
16// Oh, and we also make sure they can be used in a constexpr context.
17constexpr bool constexpr_context() {
18 int x = 0, y = 1;
19 hana::detail::constexpr_swap(x, y);
20
21 int array[6] = {1, 2, 3, 4, 5, 6};
22 int* first = array;
23 int* last = array + 6;
24
25 hana::detail::reverse(first, last);
26
27 hana::detail::next_permutation(first, last, hana::less);
28 hana::detail::next_permutation(first, last);
29
30 hana::detail::lexicographical_compare(first, last, first, last, hana::less);
31 hana::detail::lexicographical_compare(first, last, first, last);
32
33 hana::detail::equal(first, last, first, last, hana::equal);
34 hana::detail::equal(first, last, first, last);
35
36 hana::detail::sort(first, last, hana::equal);
37 hana::detail::sort(first, last);
38
39 hana::detail::find(first, last, 3);
40 hana::detail::find_if(first, last, hana::equal.to(3));
41
42 hana::detail::iota(first, last, 0);
43
44 hana::detail::count(first, last, 2);
45
46 hana::detail::accumulate(first, last, 0);
47 hana::detail::accumulate(first, last, 1, hana::mult);
48
49 hana::detail::min_element(first, last);
50
51 return true;
52}
53
54static_assert(constexpr_context(), "");
55
56int main() { }