Differential D116621 Diff 439539 libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_move.pass.cpp
Changeset View
Changeset View
Standalone View
Standalone View
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_move.pass.cpp
Show All 16 Lines | |||||
#include <tuple> | #include <tuple> | ||||
#include <string> | #include <string> | ||||
#include <memory> | #include <memory> | ||||
#include <cassert> | #include <cassert> | ||||
#include "test_macros.h" | #include "test_macros.h" | ||||
#include "allocators.h" | #include "allocators.h" | ||||
#include "test_allocator.h" | |||||
#include "../alloc_first.h" | #include "../alloc_first.h" | ||||
#include "../alloc_last.h" | #include "../alloc_last.h" | ||||
struct B | struct B | ||||
{ | { | ||||
int id_; | int id_; | ||||
explicit B(int i) : id_(i) {} | explicit B(int i) : id_(i) {} | ||||
Show All 12 Lines | struct Explicit { | ||||
explicit Explicit(int x) : value(x) {} | explicit Explicit(int x) : value(x) {} | ||||
}; | }; | ||||
struct Implicit { | struct Implicit { | ||||
int value; | int value; | ||||
Implicit(int x) : value(x) {} | Implicit(int x) : value(x) {} | ||||
}; | }; | ||||
#if _LIBCPP_STD_VER > 17 | |||||
constexpr bool alloc_move_constructor_is_constexpr() { | |||||
std::tuple<int> t1 = 1; | |||||
std::tuple<int> t2 = {std::allocator_arg, test_allocator<int>{}, std::move(t1)}; | |||||
assert(std::get<0>(t2) == 1); | |||||
return true; | |||||
} | |||||
#endif | |||||
int main(int, char**) | int main(int, char**) | ||||
{ | { | ||||
{ | { | ||||
typedef std::tuple<int> T0; | typedef std::tuple<int> T0; | ||||
typedef std::tuple<alloc_first> T1; | typedef std::tuple<alloc_first> T1; | ||||
T0 t0(2); | T0 t0(2); | ||||
alloc_first::allocator_constructed = false; | alloc_first::allocator_constructed = false; | ||||
T1 t1(std::allocator_arg, A1<int>(5), std::move(t0)); | T1 t1(std::allocator_arg, A1<int>(5), std::move(t0)); | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | int main(int, char**) | ||||
{ | { | ||||
// Test that we can use a tag derived from allocator_arg_t | // Test that we can use a tag derived from allocator_arg_t | ||||
struct DerivedFromAllocatorArgT : std::allocator_arg_t { }; | struct DerivedFromAllocatorArgT : std::allocator_arg_t { }; | ||||
DerivedFromAllocatorArgT derived; | DerivedFromAllocatorArgT derived; | ||||
std::tuple<long> from(3l); | std::tuple<long> from(3l); | ||||
std::tuple<long long> t0(derived, A1<int>(), std::move(from)); | std::tuple<long long> t0(derived, A1<int>(), std::move(from)); | ||||
} | } | ||||
#if _LIBCPP_STD_VER > 17 | |||||
static_assert(alloc_move_constructor_is_constexpr()); | |||||
#endif | |||||
return 0; | return 0; | ||||
} | } |