|
@ -31,27 +31,34 @@ namespace gp{ |
|
|
mvtor(oth.buffer, tmp); |
|
|
mvtor(oth.buffer, tmp); |
|
|
} |
|
|
} |
|
|
public: |
|
|
public: |
|
|
template<typename Uo">>//, typename std::enable_if<list_contains_class<U,T...>::value,int>::type>
|
|
|
|
|
|
k">constexpr fixed_variant(U& value) |
|
|
|
|
|
|
|
|
template<typename Up">, typename = std::enable_if_t<list_contains_class<gp::remove_cvref_t<U>,T...>::value,int>> |
|
|
|
|
|
fixed_variant(U& value) |
|
|
: index{r_index_of<U, T...>::value} |
|
|
: index{r_index_of<U, T...>::value} |
|
|
{ |
|
|
{ |
|
|
new(buffer) U(value); |
|
|
|
|
|
dtor = gp::function<void(void*)>([](void* thing){((U*)thing)->~U();}, nullopt); |
|
|
|
|
|
cpytor = gp::function<void(void*, void*)>([](void* src, void* dest){new(dest) U(*(U*)src);}, nullopt); |
|
|
|
|
|
mvtor = gp::function<void(void*, void*)>([](void* src, void* dest){new(dest) U(gp::move(*(U*)src));}, nullopt); |
|
|
|
|
|
|
|
|
using actual = gp::remove_cvref_t<U>; |
|
|
|
|
|
new(buffer) actual(value); |
|
|
|
|
|
dtor = gp::function<void(void*)>([](void* thing){((actual*)thing)->~actual();}, nullopt); |
|
|
|
|
|
cpytor = gp::function<void(void*, void*)>([](void* src, void* dest){new(dest) actual(*(actual*)src);}, nullopt); |
|
|
|
|
|
mvtor = gp::function<void(void*, void*)>([](void* src, void* dest){new(dest) actual(gp::move(*(actual*)src));}, nullopt); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
template<typename U>//, typename std::enable_if<list_contains_class<U,T...>::value,int>::type>
|
|
|
|
|
|
constexpr fixed_variant(U&& value) |
|
|
|
|
|
|
|
|
static_assert(list_contains_class<int, int>::value, "list_contains_class doesn't work properly"); |
|
|
|
|
|
static_assert(list_contains_class<int, char, int>::value, "list_contains_class doesn't work properly"); |
|
|
|
|
|
static_assert(list_contains_class<int, int, char>::value, "list_contains_class doesn't work properly"); |
|
|
|
|
|
static_assert(list_contains_class<int, char, int, char>::value, "list_contains_class doesn't work properly"); |
|
|
|
|
|
|
|
|
|
|
|
template<typename U, typename = std::enable_if_t<list_contains_class<gp::remove_cvref_t<U>,T...>::value,int>> |
|
|
|
|
|
fixed_variant(U&& value) |
|
|
: index{r_index_of<U, T...>::value} |
|
|
: index{r_index_of<U, T...>::value} |
|
|
{ |
|
|
{ |
|
|
new(buffer) U(std::move(value)); |
|
|
|
|
|
dtor = gp::function<void(void*)>([](void* thing){((U*)thing)->~U();}, nullopt); |
|
|
|
|
|
cpytor = gp::function<void(void*, void*)>([](void* src, void* dest){new(dest) U(*(U*)src);}, nullopt); |
|
|
|
|
|
mvtor = gp::function<void(void*, void*)>([](void* src, void* dest){new(dest) U(gp::move(*(U*)src));}, nullopt); |
|
|
|
|
|
|
|
|
using actual = gp::remove_cvref_t<U>; |
|
|
|
|
|
new(buffer) actual(std::move(value)); |
|
|
|
|
|
dtor = gp::function<void(void*)>([](void* thing){((actual*)thing)->~actual();}, nullopt); |
|
|
|
|
|
cpytor = gp::function<void(void*, void*)>([](void* src, void* dest){new(dest) actual(*(actual*)src);}, nullopt); |
|
|
|
|
|
mvtor = gp::function<void(void*, void*)>([](void* src, void* dest){new(dest) actual(gp::move(*(actual*)src));}, nullopt); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
k">constexpr fixed_variant(fixed_variant& oth) |
|
|
|
|
|
|
|
|
fixed_variant(fixed_variant& oth) |
|
|
: index{oth.index} |
|
|
: index{oth.index} |
|
|
, dtor{oth.dtor} |
|
|
, dtor{oth.dtor} |
|
|
, cpytor{oth.cpytor} |
|
|
, cpytor{oth.cpytor} |
|
@ -60,7 +67,7 @@ namespace gp{ |
|
|
cpytor(oth.buffer, buffer); |
|
|
cpytor(oth.buffer, buffer); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
k">constexpr fixed_variant(fixed_variant&& oth) |
|
|
|
|
|
|
|
|
fixed_variant(fixed_variant&& oth) |
|
|
{ |
|
|
{ |
|
|
mvtor(buffer, oth.buffer); |
|
|
mvtor(buffer, oth.buffer); |
|
|
gp::swap(dtor, oth.dtor); |
|
|
gp::swap(dtor, oth.dtor); |
|
|