| 15 | |
| 16 | |
| 17 | int main() { |
| 18 | |
| 19 | { |
| 20 | |
| 21 | //! [make<tuple_tag>] |
| 22 | auto xs = hana::make<hana::tuple_tag>(1, 2.2, 'a', "bcde"s); |
| 23 | //! [make<tuple_tag>] |
| 24 | |
| 25 | }{ |
| 26 | |
| 27 | //! [make<range_tag>] |
| 28 | constexpr auto r = hana::make<hana::range_tag>(hana::int_c<3>, hana::int_c<10>); |
| 29 | static_assert(r == hana::make_range(hana::int_c<3>, hana::int_c<10>), ""); |
| 30 | //! [make<range_tag>] |
| 31 | |
| 32 | }{ |
| 33 | |
| 34 | //! [tuple_constructor] |
| 35 | hana::tuple<int, double, char, std::string> xs{1, 2.2, 'a', "bcde"s}; |
| 36 | //! [tuple_constructor] |
| 37 | (void)xs; |
| 38 | |
| 39 | }{ |
| 40 | |
| 41 | //! [types] |
| 42 | auto xs = hana::make_tuple(1, '2', "345"); |
| 43 | auto 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] |
| 52 | hana::tuple<int, char, char const*> xs = hana::make_tuple(1, '2', "345"); |
| 53 | auto 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] |
| 62 | std::string hello = "Hello"; |
| 63 | std::vector<char> world = {'W', 'o', 'r', 'l', 'd'}; |
| 64 | |
| 65 | // hello is copied, world is moved-in |
| 66 | auto 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. |
| 70 | std::string& s = xs[0_c]; |
| 71 | //! [lifetime] |
| 72 | (void)s; |
| 73 | |
| 74 | }{ |