summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/std/variant
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/include/std/variant')
-rw-r--r--libstdc++-v3/include/std/variant38
1 files changed, 22 insertions, 16 deletions
diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index 272b2a6f6d2..c822953ecb1 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -44,6 +44,9 @@
#include <bits/invoke.h>
#include <ext/aligned_buffer.h>
#include <bits/parse_numbers.h>
+#include <bits/stl_iterator_base_types.h>
+#include <bits/stl_iterator_base_funcs.h>
+#include <bits/stl_construct.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
@@ -238,30 +241,32 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Various functions as "vtable" entries, where those vtables are used by
// polymorphic operations.
template<typename _Lhs, typename _Rhs>
- constexpr void
+ void
__erased_ctor(void* __lhs, void* __rhs)
- { ::new (__lhs) remove_reference_t<_Lhs>(__ref_cast<_Rhs>(__rhs)); }
+ {
+ using _Type = remove_reference_t<_Lhs>;
+ ::new (__lhs) _Type(__variant::__ref_cast<_Rhs>(__rhs));
+ }
template<typename _Variant, size_t _Np>
- constexpr void
+ void
__erased_dtor(_Variant&& __v)
- {
- auto&& __element = __get<_Np>(std::forward<_Variant>(__v));
- using _Type = std::remove_reference_t<decltype(__element)>;
- __element.~_Type();
- }
+ { std::_Destroy(std::__addressof(__get<_Np>(__v))); }
template<typename _Lhs, typename _Rhs>
- constexpr void
+ void
__erased_assign(void* __lhs, void* __rhs)
- { __ref_cast<_Lhs>(__lhs) = __ref_cast<_Rhs>(__rhs); }
+ {
+ __variant::__ref_cast<_Lhs>(__lhs) = __variant::__ref_cast<_Rhs>(__rhs);
+ }
template<typename _Lhs, typename _Rhs>
- constexpr void
+ void
__erased_swap(void* __lhs, void* __rhs)
{
using std::swap;
- swap(__ref_cast<_Lhs>(__lhs), __ref_cast<_Rhs>(__rhs));
+ swap(__variant::__ref_cast<_Lhs>(__lhs),
+ __variant::__ref_cast<_Rhs>(__rhs));
}
#define _VARIANT_RELATION_FUNCTION_TEMPLATE(__OP, __NAME) \
@@ -283,11 +288,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#undef _VARIANT_RELATION_FUNCTION_TEMPLATE
template<typename _Tp>
- constexpr size_t
+ size_t
__erased_hash(void* __t)
{
return std::hash<remove_cv_t<remove_reference_t<_Tp>>>{}(
- __ref_cast<_Tp>(__t));
+ __variant::__ref_cast<_Tp>(__t));
}
// Defines members and ctors.
@@ -936,9 +941,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
noexcept((is_nothrow_move_constructible_v<_Types> && ...)) = default;
template<typename _Tp,
+ typename = enable_if_t<!is_same_v<decay_t<_Tp>, variant>>,
+ typename = enable_if_t<(sizeof...(_Types)>0)>,
typename = enable_if_t<__exactly_once<__accepted_type<_Tp&&>>
- && is_constructible_v<__accepted_type<_Tp&&>, _Tp&&>
- && !is_same_v<decay_t<_Tp>, variant>>>
+ && is_constructible_v<__accepted_type<_Tp&&>, _Tp&&>>>
constexpr
variant(_Tp&& __t)
noexcept(is_nothrow_constructible_v<__accepted_type<_Tp&&>, _Tp&&>)