| 1 |
// { dg-do compile { target c++17 } } |
| 2 |
|
| 3 |
#include <tuple> |
| 4 |
#include <utility> |
| 5 |
|
| 6 |
struct Two |
| 7 |
{ |
| 8 |
Two(const char*, int); |
| 9 |
}; |
| 10 |
|
| 11 |
void |
| 12 |
test_pair() |
| 13 |
{ |
| 14 |
auto two = std::make_from_tuple<Two>(std::pair("one", 2)); |
| 15 |
static_assert(std::is_same_v<decltype(two), Two>, "make from pair"); |
| 16 |
} |
| 17 |
|
| 18 |
#include <array> |
| 19 |
|
| 20 |
struct Three |
| 21 |
{ |
| 22 |
Three(int, int, int); |
| 23 |
}; |
| 24 |
|
| 25 |
void |
| 26 |
test_array() |
| 27 |
{ |
| 28 |
Three three = std::make_from_tuple<Three>(std::array<int, 3>{{1, 2, 3}}); |
| 29 |
static_assert(std::is_same_v<decltype(three), Three>, "make from array"); |
| 30 |
} |
| 31 |
|
| 32 |
#if __cplusplus >= 202002L |
| 33 |
#include <vector> |
| 34 |
#include <ranges> |
| 35 |
|
| 36 |
void |
| 37 |
test_subrange() // PR libstdc++/102301 |
| 38 |
{ |
| 39 |
auto r = std::views::iota(0, 5); |
| 40 |
auto v = std::make_from_tuple<std::vector<int>>(std::ranges::subrange(r)); |
| 41 |
static_assert(std::is_same_v<decltype(v), std::vector<int>>, "from subrange"); |
| 42 |
} |
| 43 |
#endif |