MCPcopy Create free account
hub / github.com/boostorg/hana / constexpr_context

Function constexpr_context

test/detail/algorithm.cpp:17–52  ·  view source on GitHub ↗

The algorithms are taken from the suggested implementations on cppreference. Hence, we assume them to be correct and we only make sure they compile, to avoid stupid mistakes I could have made when copy/pasting and editing. Oh, and we also make sure they can be used in a constexpr context.

Source from the content-addressed store, hash-verified

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

Callers 1

algorithm.cppFile · 0.70

Calls 12

constexpr_swapFunction · 0.85
next_permutationFunction · 0.85
lexicographical_compareFunction · 0.85
iotaFunction · 0.85
accumulateFunction · 0.85
reverseClass · 0.50
equalClass · 0.50
sortClass · 0.50
findClass · 0.50
find_ifClass · 0.50
countClass · 0.50
min_elementClass · 0.50

Tested by

no test coverage detected