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

Function main

example/tutorial/containers.cpp:17–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16
17int main() {
18
19{
20
21//! [make<tuple_tag>]
22auto xs = hana::make<hana::tuple_tag>(1, 2.2, 'a', "bcde"s);
23//! [make<tuple_tag>]
24
25}{
26
27//! [make<range_tag>]
28constexpr auto r = hana::make<hana::range_tag>(hana::int_c<3>, hana::int_c<10>);
29static_assert(r == hana::make_range(hana::int_c<3>, hana::int_c<10>), "");
30//! [make<range_tag>]
31
32}{
33
34//! [tuple_constructor]
35hana::tuple<int, double, char, std::string> xs{1, 2.2, 'a', "bcde"s};
36//! [tuple_constructor]
37(void)xs;
38
39}{
40
41//! [types]
42auto xs = hana::make_tuple(1, '2', "345");
43auto ints = hana::make_range(hana::int_c<0>, hana::int_c<100>);
44// what can we say about the types of `xs` and `ints`?
45//! [types]
46(void)xs;
47(void)ints;
48
49}{
50
51//! [types_maximally_specified]
52hana::tuple<int, char, char const*> xs = hana::make_tuple(1, '2', "345");
53auto ints = hana::make_range(hana::int_c<0>, hana::int_c<100>);
54// can't specify the type of ints, however
55//! [types_maximally_specified]
56(void)xs;
57(void)ints;
58
59}{
60
61//! [lifetime]
62std::string hello = "Hello";
63std::vector<char> world = {'W', 'o', 'r', 'l', 'd'};
64
65// hello is copied, world is moved-in
66auto xs = hana::make_tuple(hello, std::move(world));
67
68// s is a reference to the copy of hello inside xs.
69// It becomes a dangling reference as soon as xs is destroyed.
70std::string& s = xs[0_c];
71//! [lifetime]
72(void)s;
73
74}{

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected