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

Function main

example/tutorial/algorithms.cpp:17–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16
17int main() {
18
19{
20
21//! [reverse_transform]
22auto to_str = [](auto const& x) {
23 std::stringstream ss;
24 ss << x;
25 return ss.str();
26};
27
28auto xs = hana::make_tuple(1, 2.2, 'a', "bcde");
29
30BOOST_HANA_RUNTIME_CHECK(
31 hana::reverse(hana::transform(xs, to_str)) == hana::make_tuple("bcde", "a", "2.2", "1")
32);
33//! [reverse_transform]
34
35//! [reverse_transform_copy]
36hana::reverse(
37 hana::transform(xs, to_str) // <-- copy into reverse(...) here?
38);
39//! [reverse_transform_copy]
40
41//! [reverse_transform_move]
42hana::reverse(
43 hana::transform(xs, to_str) // <-- nope, move from the temporary instead!
44);
45//! [reverse_transform_move]
46
47}{
48
49//! [effects]
50auto r = hana::any_of(hana::make_tuple("hello"s, 1.2, 3), [](auto x) {
51 return std::is_integral<decltype(x)>{};
52});
53
54BOOST_HANA_CONSTANT_CHECK(r);
55//! [effects]
56
57{
58
59//! [effects.codegen]
60auto xs = hana::make_tuple("hello"s, 1.2, 3);
61auto pred = [](auto x) { return std::is_integral<decltype(x)>{}; };
62
63auto r = hana::bool_c<
64 decltype(pred(xs[0_c]))::value ? true :
65 decltype(pred(xs[1_c]))::value ? true :
66 decltype(pred(xs[2_c]))::value ? true :
67 false
68>;
69
70BOOST_HANA_CONSTANT_CHECK(r);
71//! [effects.codegen]
72
73}
74

Callers

nothing calls this directly

Calls 3

transformClass · 0.85
any_ofClass · 0.85
reverseClass · 0.70

Tested by

no test coverage detected