Re: [Patches] Add variant constexpr support for visit, comparisons and get

2016-12-06 Thread Tim Shen
On Tue, Dec 6, 2016 at 6:37 AM, Jonathan Wakely  wrote:
> On 06/12/16 12:49 +, Jonathan Wakely wrote:
>>
>> On 06/12/16 03:52 -0800, Tim Shen wrote:
>>>
>>> On Tue, Dec 6, 2016 at 2:30 AM, Jonathan Wakely wrote:

 This looks good - OK for trunk, thanks!
>>>
>>>
>>> Committed.
>>>
>>> Thanks!
>>
>>
>> ChangeLog dates fixed by this patch.
>
>
> And pretty printer fixed by this one.
>
> The "vref" test originally testsed variant but is no
> longer needed, as that isn't supported.
>
> Tested x86_64-linux, committed to trunk.
>

Thanks!

Just figured out that I need to run prettyprinters.exp (I usually just
run "conformance.exp=20_util/variant/*") to catch the failures...


-- 
Regards,
Tim Shen


Re: [Patches] Add variant constexpr support for visit, comparisons and get

2016-12-06 Thread Jonathan Wakely

On 06/12/16 12:49 +, Jonathan Wakely wrote:

On 06/12/16 03:52 -0800, Tim Shen wrote:

On Tue, Dec 6, 2016 at 2:30 AM, Jonathan Wakely wrote:

This looks good - OK for trunk, thanks!


Committed.

Thanks!


ChangeLog dates fixed by this patch.


And pretty printer fixed by this one.

The "vref" test originally testsed variant but is no
longer needed, as that isn't supported.

Tested x86_64-linux, committed to trunk.

commit 2f135ef76712b96e3dd799dfbb17e8d16545b115
Author: Jonathan Wakely 
Date:   Tue Dec 6 14:24:13 2016 +

Fix pretty-printer for std::variant

	* python/libstdcxx/v6/printers.py (StdVariantPrinter): Update for new
	data member name.
	* testsuite/libstdc++-prettyprinters/cxx17.cc: Remove redundant test.

diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index bad42b4..ff428e8 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -1002,7 +1002,7 @@ class StdVariantPrinter(SingleObjContainerPrinter):
 visualizer = None
 else:
 self.contained_type = alternatives[int(self.index)]
-addr = val['_M_union']['_M_first']['_M_storage'].address
+addr = val['_M_u']['_M_first']['_M_storage'].address
 contained_value = addr.cast(self.contained_type.pointer()).dereference()
 visualizer = gdb.default_visualizer(contained_value)
 super (StdVariantPrinter, self).__init__(contained_value, visualizer, 'array')
diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc
index 96be8c7..69c16c1 100644
--- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc
@@ -86,8 +86,6 @@ main()
 // { dg-final { note-test v3 {std::variant [index 1] = {3}} } }
   variant v4{ str };
 // { dg-final { note-test v4 {std::variant [index 2] = {"string"}} } }
-  variant vref{str};
-// { dg-final { note-test vref {std::variant [index 0] = {"string"}} } }
 
   map m{ {1, "one"} };
   map::node_type n0;


Re: [Patches] Add variant constexpr support for visit, comparisons and get

2016-12-06 Thread Jonathan Wakely

On 06/12/16 03:52 -0800, Tim Shen wrote:

On Tue, Dec 6, 2016 at 2:30 AM, Jonathan Wakely wrote:

This looks good - OK for trunk, thanks!


Committed.

Thanks!


ChangeLog dates fixed by this patch.

commit c3651cf0403b826414b8376bb29b4757530f4eec
Author: redi 
Date:   Tue Dec 6 12:48:54 2016 +

Fix libstdc++-v3/ChangeLog dates

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@243299 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 47e9abf..b8edb7b 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -9,14 +9,14 @@
 	Guard with #ifndef __cpp_lib_addressof_constexpr.
 	(operator->()): Use std::__addressof if it's constexpr.
 
-2016-11-27  Tim Shen  
+2016-12-06  Tim Shen  
 
 	* include/std/variant (visit): Make visit constexpr. Also cleanup
 	__get_alternative and __storage, since we don't support reference/void
 	alternatives any more.
 	* testsuite/20_util/variant/compile.cc: Add tests.
 
-2016-12-07  Tim Shen  
+2016-12-06  Tim Shen  
 
 	* include/bits/enable_special_members.h: Make
 	_Enable_default_constructor constexpr.
@@ -24,13 +24,13 @@
 	std::hash): Sfinae on emplace and std::swap; handle __poison_hash bases
 	of duplicated types.
 
-2016-12-07  Tim Shen  
+2016-12-06  Tim Shen  
 
 	* include/std/variant (std::get, operator==): Implement constexpr
 	comparison and get<>.
 	* testsuite/20_util/variant/compile.cc: Tests.
 
-2016-12-07  Tim Shen  
+2016-12-06  Tim Shen  
 
 	* include/std/variant (__erased_use_alloc_ctor,
 	_Variant_base::_Variant_base, variant::variant): Remove uses-allocator


Re: [Patches] Add variant constexpr support for visit, comparisons and get

2016-12-06 Thread Tim Shen
On Tue, Dec 6, 2016 at 2:30 AM, Jonathan Wakely wrote:
> This looks good - OK for trunk, thanks!

Committed.

Thanks!


-- 
Regards,
Tim Shen


Re: [Patches] Add variant constexpr support for visit, comparisons and get

2016-12-06 Thread Jonathan Wakely

On 02/12/16 19:14 -0800, Tim Shen wrote:

On Wed, Nov 30, 2016 at 8:27 AM, Jonathan Wakely wrote:

On 26/11/16 21:38 -0800, Tim Shen wrote:


This 4-patch series contains the following in order:

a.diff: Remove uses-allocator ctors. They are going away, and removing
it reduces the maintenance burden from now on.



Yay! less code.


Yay! Also removed the unused #include.




-  template>
+  // _Uninitialized nullify the destructor calls.



This wording confused me slightly. How about:

 "_Uninitialized makes destructors trivial"


Change this section of comment to the discussed content.




+  // This is necessary, since we define _Variadic_union as a recursive
union,
+  // and we don't want to inspect the union members one by one in its
dtor,
+  // it's slow.



Please change "it's slow" to "that's slow".


N/A.




+  template>
struct _Uninitialized;



I'm still unsure that is_literal_type is the right trait here. If it's
definitely right then we should probably *not* deprecate it in C++17!


Already discussed.




  template
struct _Uninitialized<_Type, false>
{
-  constexpr _Uninitialized() = default;
-
  template
  constexpr _Uninitialized(in_place_index_t<0>, _Args&&... __args)
  { ::new (&_M_storage) _Type(std::forward<_Args>(__args)...); }

+  const _Type& _M_get() const &
+  {
+   return *static_cast(
+   static_cast(&_M_storage));
+  }
+
+  _Type& _M_get() &
+  { return *static_cast<_Type*>(static_cast(&_M_storage)); }
+
+  const _Type&& _M_get() const &&
+  {
+   return std::move(*static_cast(
+   static_cast(&_M_storage)));
+  }
+
+  _Type&& _M_get() &&
+  {
+   return
std::move(*static_cast<_Type*>(static_cast(&_M_storage)));
+  }
+
  typename std::aligned_storage::type
  _M_storage;



I think this could use __aligned_membuf, which would reduce the
alignment requirements for some types (e.g. long long on x86-32).


Done.



That would also mean you get the _M_ptr() member so don't need all the
casts.


+  ~_Variant_storage()
+  { _M_destroy_impl(std::make_index_sequence{}); }



You can use index_sequence_for<_Types...> here.


Done




@@ -598,9 +645,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_S_apply_all_alts(_Array_type& __vtable,
index_sequence<__indices...>)
{ (_S_apply_single_alt<__indices>(__vtable._M_arr[__indices]),
...); }

-  template
+  template



This needs to be _Tp not T


Done.




+  return __lhs._M_equal_to(__rhs,
+
std::make_index_sequence{});



Another one that could use index_sequence_for<_Types...>


Done.




+  return __lhs._M_less_than(__rhs,
+
std::make_index_sequence{});



Same again.


Same again. ;)





   * include/bits/enable_special_members.h: Make
   _Enable_default_constructor constexpr.
   * include/std/variant (variant::emplace, variant::swap,
std::swap,
   std::hash): Sfinae on emplace and std::swap; handle
__poison_hash bases
   of duplicated types.

diff --git a/libstdc++-v3/include/bits/enable_special_members.h
b/libstdc++-v3/include/bits/enable_special_members.h
index 07c6c99..4f4477b 100644
--- a/libstdc++-v3/include/bits/enable_special_members.h
+++ b/libstdc++-v3/include/bits/enable_special_members.h
@@ -118,7 +118,8 @@ template
operator=(_Enable_default_constructor&&) noexcept = default;

// Can be used in other ctors.
-explicit _Enable_default_constructor(_Enable_default_constructor_tag)
{ }
+constexpr explicit
+_Enable_default_constructor(_Enable_default_constructor_tag) { }
  };

+  void _M_reset()
+  {
+   _M_reset_impl(std::make_index_sequence{});
+   _M_index = variant_npos;
+  }
+
  ~_Variant_storage()
-  { _M_destroy_impl(std::make_index_sequence{}); }
+  { _M_reset(); }



These can also use index_sequence_for<_Types...>


Done.




@@ -1253,14 +1285,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION

  template
struct hash>
-: private __poison_hash>...
+: private __detail::__variant::_Variant_hash_base<
+   variant<_Types...>, std::make_index_sequence>



And again.


And again.




{
  using result_type = size_t;
  using argument_type = variant<_Types...>;

  size_t
  operator()(const variant<_Types...>& __t) const
-  noexcept((... &&
noexcept(hash>{}(std::declval<_Types>()
+  noexcept((noexcept(hash>{}(std::declval<_Types>()))
+   && ...))



This could be
__and_>(_Types)>...>
but I'm not sure it would be an improvement. The is_callable check is
expensive, but maybe we need it anyway to correctly disable this
function if the hash specialization should be posisoned?


Done. I 

Re: [Patches] Add variant constexpr support for visit, comparisons and get

2016-12-02 Thread Tim Shen
On Wed, Nov 30, 2016 at 8:27 AM, Jonathan Wakely wrote:
> On 26/11/16 21:38 -0800, Tim Shen wrote:
>>
>> This 4-patch series contains the following in order:
>>
>> a.diff: Remove uses-allocator ctors. They are going away, and removing
>> it reduces the maintenance burden from now on.
>
>
> Yay! less code.

Yay! Also removed the unused #include.

>
>> -  template> std::is_literal_type_v<_Type>>
>> +  // _Uninitialized nullify the destructor calls.
>
>
> This wording confused me slightly. How about:
>
>  "_Uninitialized makes destructors trivial"

Change this section of comment to the discussed content.

>
>> +  // This is necessary, since we define _Variadic_union as a recursive
>> union,
>> +  // and we don't want to inspect the union members one by one in its
>> dtor,
>> +  // it's slow.
>
>
> Please change "it's slow" to "that's slow".

N/A.

>
>> +  template>
>> struct _Uninitialized;
>
>
> I'm still unsure that is_literal_type is the right trait here. If it's
> definitely right then we should probably *not* deprecate it in C++17!

Already discussed.

>
>>   template
>> struct _Uninitialized<_Type, false>
>> {
>> -  constexpr _Uninitialized() = default;
>> -
>>   template
>>   constexpr _Uninitialized(in_place_index_t<0>, _Args&&... __args)
>>   { ::new (&_M_storage) _Type(std::forward<_Args>(__args)...); }
>>
>> +  const _Type& _M_get() const &
>> +  {
>> +   return *static_cast(
>> +   static_cast(&_M_storage));
>> +  }
>> +
>> +  _Type& _M_get() &
>> +  { return *static_cast<_Type*>(static_cast(&_M_storage)); }
>> +
>> +  const _Type&& _M_get() const &&
>> +  {
>> +   return std::move(*static_cast(
>> +   static_cast(&_M_storage)));
>> +  }
>> +
>> +  _Type&& _M_get() &&
>> +  {
>> +   return
>> std::move(*static_cast<_Type*>(static_cast(&_M_storage)));
>> +  }
>> +
>>   typename std::aligned_storage::type
>>   _M_storage;
>
>
> I think this could use __aligned_membuf, which would reduce the
> alignment requirements for some types (e.g. long long on x86-32).

Done.

>
> That would also mean you get the _M_ptr() member so don't need all the
> casts.
>
>> +  ~_Variant_storage()
>> +  { _M_destroy_impl(std::make_index_sequence{}); }
>
>
> You can use index_sequence_for<_Types...> here.

Done

>
>> @@ -598,9 +645,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>> _S_apply_all_alts(_Array_type& __vtable,
>> index_sequence<__indices...>)
>> { (_S_apply_single_alt<__indices>(__vtable._M_arr[__indices]),
>> ...); }
>>
>> -  template
>> +  template
>
>
> This needs to be _Tp not T

Done.

>
>> +  return __lhs._M_equal_to(__rhs,
>> +
>> std::make_index_sequence{});
>
>
> Another one that could use index_sequence_for<_Types...>

Done.

>
>> +  return __lhs._M_less_than(__rhs,
>> +
>> std::make_index_sequence{});
>
>
> Same again.

Same again. ;)

>
>
>>* include/bits/enable_special_members.h: Make
>>_Enable_default_constructor constexpr.
>>* include/std/variant (variant::emplace, variant::swap,
>> std::swap,
>>std::hash): Sfinae on emplace and std::swap; handle
>> __poison_hash bases
>>of duplicated types.
>>
>> diff --git a/libstdc++-v3/include/bits/enable_special_members.h
>> b/libstdc++-v3/include/bits/enable_special_members.h
>> index 07c6c99..4f4477b 100644
>> --- a/libstdc++-v3/include/bits/enable_special_members.h
>> +++ b/libstdc++-v3/include/bits/enable_special_members.h
>> @@ -118,7 +118,8 @@ template
>> operator=(_Enable_default_constructor&&) noexcept = default;
>>
>> // Can be used in other ctors.
>> -explicit _Enable_default_constructor(_Enable_default_constructor_tag)
>> { }
>> +constexpr explicit
>> +_Enable_default_constructor(_Enable_default_constructor_tag) { }
>>   };
>>
>> +  void _M_reset()
>> +  {
>> +   _M_reset_impl(std::make_index_sequence{});
>> +   _M_index = variant_npos;
>> +  }
>> +
>>   ~_Variant_storage()
>> -  { _M_destroy_impl(std::make_index_sequence{}); }
>> +  { _M_reset(); }
>
>
> These can also use index_sequence_for<_Types...>

Done.

>
>> @@ -1253,14 +1285,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>>
>>   template
>> struct hash>
>> -: private __poison_hash>...
>> +: private __detail::__variant::_Variant_hash_base<
>> +   variant<_Types...>, std::make_index_sequence>
>
>
> And again.

And again.

>
>> {
>>   using result_type = size_t;
>>   using argument_type = variant<_Types...>;
>>
>>   size_t
>>   operator()(const variant<_Types...>& __t) const
>> -  noexcept((... &&
>> noexcept(hash>{}(std::declval<_Types>()
>> +  

Re: [Patches] Add variant constexpr support for visit, comparisons and get

2016-12-01 Thread Jonathan Wakely

On 30/11/16 19:29 -0800, Tim Shen wrote:

On Wed, Nov 30, 2016 at 8:27 AM, Jonathan Wakely wrote:

On 26/11/16 21:38 -0800, Tim Shen wrote:

+  template>
struct _Uninitialized;



I'm still unsure that is_literal_type is the right trait here. If it's
definitely right then we should probably *not* deprecate it in C++17!


No it's not right. We need this only because [basic.types]p10.5.3 (in n4606):

 if it (a literal type) is a union, at least one of its non-static
data members is of non-volatile literal type, ...

is not implemented. In the current GCC implementation, however, all
non-static data members need to be literal types, in order to create a
literal union.

With the current GCC implementation, to keep our goal, which is to
make _Variadic_union literal type, we need to ensure that
_Uninitialized is literal type, by specializing on T:
1) If is_literal_type_v, store a T;
2) otherwise, store a raw buffer of T.

In the future, when [basic.types]p10.5.3 is implemented, we don't need
is_literal_type_v.

I'll add a comment here.


Thanks, that will stop me asking again and again in future ;-)

I think we want to get [basic.types] p10 implemented before we declare
C++17 support non-experimental, so we don't have to change
std::variant layout later.


I didn't check for other compilers.


That's fine, the current approach should work for them too.



Re: [Patches] Add variant constexpr support for visit, comparisons and get

2016-11-30 Thread Tim Shen
On Wed, Nov 30, 2016 at 8:27 AM, Jonathan Wakely wrote:
> On 26/11/16 21:38 -0800, Tim Shen wrote:
>> +  template>
>> struct _Uninitialized;
>
>
> I'm still unsure that is_literal_type is the right trait here. If it's
> definitely right then we should probably *not* deprecate it in C++17!

No it's not right. We need this only because [basic.types]p10.5.3 (in n4606):

  if it (a literal type) is a union, at least one of its non-static
data members is of non-volatile literal type, ...

is not implemented. In the current GCC implementation, however, all
non-static data members need to be literal types, in order to create a
literal union.

With the current GCC implementation, to keep our goal, which is to
make _Variadic_union literal type, we need to ensure that
_Uninitialized is literal type, by specializing on T:
1) If is_literal_type_v, store a T;
2) otherwise, store a raw buffer of T.

In the future, when [basic.types]p10.5.3 is implemented, we don't need
is_literal_type_v.

I'll add a comment here.

I didn't check for other compilers.


-- 
Regards,
Tim Shen


Re: [Patches] Add variant constexpr support for visit, comparisons and get

2016-11-30 Thread Jonathan Wakely

On 26/11/16 21:38 -0800, Tim Shen wrote:

This 4-patch series contains the following in order:

a.diff: Remove uses-allocator ctors. They are going away, and removing
it reduces the maintenance burden from now on.


Yay! less code.


b.diff: Add constexpr support for get<> and comparisons. This patch
also involves small refactoring of _Variant_storage.

c.diff: Fix some libc++ test failures.

d.diff: Add constexpr support for visit. This patch also removes
__storage, __get_alternative, and __reserved_type_map, since we don't
need to support reference/void types for now.

The underlying design doesn't change - we still use the vtable
approach to achieve O(1) runtime cost even under -O0.


Great stuff.




   * include/std/variant: Implement constexpr comparison and get<>.
   * testsuite/20_util/variant/compile.cc: Tests.

diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index 2d9303a..a913074 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -154,31 +154,63 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  template
using __storage = _Alternative;

-  template>
+  // _Uninitialized nullify the destructor calls.


This wording confused me slightly. How about:

 "_Uninitialized makes destructors trivial"


+  // This is necessary, since we define _Variadic_union as a recursive union,
+  // and we don't want to inspect the union members one by one in its dtor,
+  // it's slow.


Please change "it's slow" to "that's slow".


+  template>
struct _Uninitialized;


I'm still unsure that is_literal_type is the right trait here. If it's
definitely right then we should probably *not* deprecate it in C++17!


  template
struct _Uninitialized<_Type, false>
{
-  constexpr _Uninitialized() = default;
-
  template
  constexpr _Uninitialized(in_place_index_t<0>, _Args&&... __args)
  { ::new (&_M_storage) _Type(std::forward<_Args>(__args)...); }

+  const _Type& _M_get() const &
+  {
+   return *static_cast(
+   static_cast(&_M_storage));
+  }
+
+  _Type& _M_get() &
+  { return *static_cast<_Type*>(static_cast(&_M_storage)); }
+
+  const _Type&& _M_get() const &&
+  {
+   return std::move(*static_cast(
+   static_cast(&_M_storage)));
+  }
+
+  _Type&& _M_get() &&
+  {
+   return std::move(*static_cast<_Type*>(static_cast(&_M_storage)));
+  }
+
  typename std::aligned_storage::type
  _M_storage;


I think this could use __aligned_membuf, which would reduce the
alignment requirements for some types (e.g. long long on x86-32).

That would also mean you get the _M_ptr() member so don't need all the
casts.


+  ~_Variant_storage()
+  { _M_destroy_impl(std::make_index_sequence{}); }


You can use index_sequence_for<_Types...> here.


@@ -598,9 +645,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_S_apply_all_alts(_Array_type& __vtable, index_sequence<__indices...>)
{ (_S_apply_single_alt<__indices>(__vtable._M_arr[__indices]), ...); }

-  template
+  template


This needs to be _Tp not T


+  return __lhs._M_equal_to(__rhs,
+  std::make_index_sequence{});


Another one that could use index_sequence_for<_Types...>


+  return __lhs._M_less_than(__rhs,
+   std::make_index_sequence{});


Same again.



   * include/bits/enable_special_members.h: Make
   _Enable_default_constructor constexpr.
   * include/std/variant (variant::emplace, variant::swap, std::swap,
   std::hash): Sfinae on emplace and std::swap; handle __poison_hash 
bases
   of duplicated types.

diff --git a/libstdc++-v3/include/bits/enable_special_members.h 
b/libstdc++-v3/include/bits/enable_special_members.h
index 07c6c99..4f4477b 100644
--- a/libstdc++-v3/include/bits/enable_special_members.h
+++ b/libstdc++-v3/include/bits/enable_special_members.h
@@ -118,7 +118,8 @@ template
operator=(_Enable_default_constructor&&) noexcept = default;

// Can be used in other ctors.
-explicit _Enable_default_constructor(_Enable_default_constructor_tag) { }
+constexpr explicit
+_Enable_default_constructor(_Enable_default_constructor_tag) { }
  };

+  void _M_reset()
+  {
+   _M_reset_impl(std::make_index_sequence{});
+   _M_index = variant_npos;
+  }
+
  ~_Variant_storage()
-  { _M_destroy_impl(std::make_index_sequence{}); }
+  { _M_reset(); }


These can also use index_sequence_for<_Types...>


@@ -1253,14 +1285,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION

  template
struct hash>
-: private __poison_hash>...
+: private __detail::__variant::_Variant_hash_base<
+   variant<_Types...>, std::make_index_sequence>



[Patches] Add variant constexpr support for visit, comparisons and get

2016-11-26 Thread Tim Shen
This 4-patch series contains the following in order:

a.diff: Remove uses-allocator ctors. They are going away, and removing
it reduces the maintenance burden from now on.

b.diff: Add constexpr support for get<> and comparisons. This patch
also involves small refactoring of _Variant_storage.

c.diff: Fix some libc++ test failures.

d.diff: Add constexpr support for visit. This patch also removes
__storage, __get_alternative, and __reserved_type_map, since we don't
need to support reference/void types for now.

The underlying design doesn't change - we still use the vtable
approach to achieve O(1) runtime cost even under -O0.

Bootstrapped and tested for each of them.

Thanks!


-- 
Regards,
Tim Shen
commit 638ecd4cf354d853bb12b089a356df99531f9afa
Author: Tim Shen 
Date:   Thu Nov 24 00:56:08 2016 -0800

2016-11-26  Tim Shen  

* include/std/variant (__erased_use_alloc_ctor,
_Variant_base::_Variant_base, variant::variant): Remove uses-allocator
related functions.
* testsuite/20_util/variant/compile.cc: Remove related tests.
* testsuite/20_util/variant/run.cc: Remove related tests.

diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index 34ad3fd..2d9303a 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -202,14 +202,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 __erased_ctor(void* __lhs, void* __rhs)
 { ::new (__lhs) decay_t<_Lhs>(__get_alternative<_Rhs>(__rhs)); }
 
-  template
-constexpr void
-__erased_use_alloc_ctor(const _Alloc& __a, void* __lhs, void* __rhs)
-{
-  __uses_allocator_construct(__a, static_cast*>(__lhs),
- __get_alternative<_Rhs>(__rhs));
-}
-
   // TODO: Find a potential chance to reuse this accross the project.
   template
 constexpr void
@@ -353,47 +345,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	: _Storage(__i, std::forward<_Args>(__args)...), _M_index(_Np)
 	{ }
 
-  template
-	_Variant_base(const _Alloc& __a, const _Variant_base& __rhs)
-	: _Storage(), _M_index(__rhs._M_index)
-	{
-	  if (__rhs._M_valid())
-	{
-	  static constexpr void
-	  (*_S_vtable[])(const _Alloc&, void*, void*) =
-		{ &__erased_use_alloc_ctor<_Alloc, __storage<_Types>&,
-	   const __storage<_Types>&>... };
-	  _S_vtable[__rhs._M_index](__a, _M_storage(), __rhs._M_storage());
-	}
-	}
-
-  template
-	_Variant_base(const _Alloc& __a, _Variant_base&& __rhs)
-	: _Storage(), _M_index(__rhs._M_index)
-	{
-	  if (__rhs._M_valid())
-	{
-	  static constexpr void
-	  (*_S_vtable[])(const _Alloc&, void*, void*) =
-		{ &__erased_use_alloc_ctor<_Alloc, __storage<_Types>&,
-	   __storage<_Types>&&>... };
-	  _S_vtable[__rhs._M_index](__a, _M_storage(), __rhs._M_storage());
-	}
-	}
-
-  template
-	constexpr explicit
-	_Variant_base(const _Alloc& __a, in_place_index_t<_Np>,
-		  _Args&&... __args)
-	: _Storage(), _M_index(_Np)
-	{
-	  using _Storage =
-	__storage>>;
-	  __uses_allocator_construct(__a, static_cast<_Storage*>(_M_storage()),
- std::forward<_Args>(__args)...);
-	  __glibcxx_assert(_M_index == _Np);
-	}
-
   _Variant_base&
   operator=(const _Variant_base& __rhs)
   {
@@ -1026,84 +977,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	_Default_ctor_enabler(_Enable_default_constructor_tag{})
 	{ __glibcxx_assert(index() == _Np); }
 
-  template, _Alloc>>>
-	variant(allocator_arg_t, const _Alloc& __a)
-	: variant(allocator_arg, __a, in_place_index<0>)
-	{ }
-
-  template>>...>::value>>
-	variant(allocator_arg_t, const _Alloc& __a, const variant& __rhs)
-	: _Base(__a, __rhs),
-	_Default_ctor_enabler(_Enable_default_constructor_tag{})
-	{ }
-
-  template>...>::value>>
-	variant(allocator_arg_t, const _Alloc& __a, variant&& __rhs)
-	: _Base(__a, std::move(__rhs)),
-	_Default_ctor_enabler(_Enable_default_constructor_tag{})
-	{ }
-
-  template>
-		 && __is_uses_allocator_constructible_v<
-		   __accepted_type<_Tp&&>, _Alloc, _Tp&&>
-		 && !is_same_v, variant>, variant&>>
-	variant(allocator_arg_t, const _Alloc& __a, _Tp&& __t)
-	: variant(allocator_arg, __a, in_place_index<__accepted_index<_Tp&&>>,
-		  std::forward<_Tp>(__t))
-	{ __glibcxx_assert(holds_alternative<__accepted_type<_Tp&&>>(*this)); }
-
-  template
-		 && __is_uses_allocator_constructible_v<
-		   _Tp, _Alloc, _Args&&...>>>
-	variant(allocator_arg_t, const _Alloc& __a, in_place_type_t<_Tp>,
-		_Args&&... __args)
-	: variant(allocator_arg, __a, in_place_index<__index_of<_Tp>>,
-		  std::forward<_Args>(__args)...)
-	{ __glibcxx_assert(holds_alternative<_Tp>(*this)); }
-
-  template
-		 && __is_uses_allocator_constructible_v<
-		   _Tp, _Alloc, initializer_list<_Up>&, _Args&&...>>>
-	variant(allocator_arg_t, const _Alloc& __a, in_place_type_t<_Tp>,
-		initializer_list<_Up> __il, _Args&&...