From: Tim Shen Date: Tue, 6 Dec 2016 11:17:56 +0000 (+0000) Subject: variant (__erased_use_alloc_ctor, [...]): Remove uses-allocator related functions. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=44f46885959d501929eeca3d3618db6db6d50c77;p=gcc.git variant (__erased_use_alloc_ctor, [...]): Remove uses-allocator related functions. * 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. From-SVN: r243292 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 5dd75042480..ecda02675cf 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2016-12-07 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. + 2016-12-06 Aditya Kumar * src/c++11/shared_ptr.cc (_Sp_locker::_Sp_locker(const void* p)): Add diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index 89ca9798609..32c0dc3c07a 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -40,7 +40,6 @@ #include #include #include -#include #include namespace std _GLIBCXX_VISIBILITY(default) @@ -202,14 +201,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 +344,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) { @@ -1033,84 +983,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&&... __args) - : variant(allocator_arg, __a, in_place_index<__index_of<_Tp>>, __il, - std::forward<_Args>(__args)...) - { __glibcxx_assert(holds_alternative<_Tp>(*this)); } - - template, _Alloc, _Args&&...>>> - variant(allocator_arg_t, const _Alloc& __a, in_place_index_t<_Np>, - _Args&&... __args) - : _Base(__a, in_place_index<_Np>, std::forward<_Args>(__args)...), - _Default_ctor_enabler(_Enable_default_constructor_tag{}) - { __glibcxx_assert(index() == _Np); } - - template, _Alloc, initializer_list<_Up>&, _Args&&...>>> - variant(allocator_arg_t, const _Alloc& __a, in_place_index_t<_Np>, - initializer_list<_Up> __il, _Args&&... __args) - : _Base(__a, in_place_index<_Np>, __il, std::forward<_Args>(__args)...), - _Default_ctor_enabler(_Enable_default_constructor_tag{}) - { __glibcxx_assert(index() == _Np); } - ~variant() = default; variant& operator=(const variant&) = default; @@ -1300,10 +1172,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __detail::__variant::__get_storage(__variants)...); } - template - struct uses_allocator, _Alloc> - : true_type { }; - template struct hash> : private __poison_hash>... diff --git a/libstdc++-v3/testsuite/20_util/variant/compile.cc b/libstdc++-v3/testsuite/20_util/variant/compile.cc index 8250a9522f8..a67b651586b 100644 --- a/libstdc++-v3/testsuite/20_util/variant/compile.cc +++ b/libstdc++-v3/testsuite/20_util/variant/compile.cc @@ -117,31 +117,6 @@ void in_place_type_ctor() static_assert(!is_constructible_v, in_place_type_t, const char*>, ""); } -void uses_alloc_ctors() -{ - std::allocator alloc; - variant a(allocator_arg, alloc); - static_assert(!is_constructible_v, allocator_arg_t, std::allocator>, ""); - { - variant b(allocator_arg, alloc, "a"); - static_assert(!is_constructible_v, allocator_arg_t, std::allocator, const char*>, ""); - } - { - variant b(allocator_arg, alloc, in_place_index<0>, "a"); - variant c(allocator_arg, alloc, in_place_index<1>, "a"); - } - { - variant b(allocator_arg, alloc, in_place_index<0>, {'a'}); - variant c(allocator_arg, alloc, in_place_index<1>, {'a'}); - } - { - variant b(allocator_arg, alloc, in_place_type, "a"); - } - { - variant b(allocator_arg, alloc, in_place_type, {'a'}); - } -} - void dtor() { static_assert(is_destructible_v>, ""); @@ -324,9 +299,7 @@ namespace adl_trap void test_adl() { using adl_trap::X; - using std::allocator_arg; X x; - std::allocator a; std::initializer_list il; adl_trap::Visitor vis; @@ -339,11 +312,6 @@ void test_adl() variant v2{in_place_type, x}; variant v3{in_place_index<0>, il, x}; variant v4{in_place_type, il, x}; - variant v5{allocator_arg, a, in_place_index<0>, x}; - variant v6{allocator_arg, a, in_place_type, x}; - variant v7{allocator_arg, a, in_place_index<0>, il, x}; - variant v8{allocator_arg, a, in_place_type, il, x}; - variant v9{allocator_arg, a, in_place_type, 1}; } void test_variant_alternative() { diff --git a/libstdc++-v3/testsuite/20_util/variant/run.cc b/libstdc++-v3/testsuite/20_util/variant/run.cc index 71e01767ff6..fb5d7c441a0 100644 --- a/libstdc++-v3/testsuite/20_util/variant/run.cc +++ b/libstdc++-v3/testsuite/20_util/variant/run.cc @@ -160,48 +160,6 @@ void in_place_type_ctor() } } -struct UsesAllocatable -{ - template - UsesAllocatable(std::allocator_arg_t, const Alloc& a) - : d(0), a(static_cast(&a)) { } - - template - UsesAllocatable(std::allocator_arg_t, const Alloc& a, const UsesAllocatable&) - : d(1), a(static_cast(&a)) { } - - template - UsesAllocatable(std::allocator_arg_t, const Alloc& a, UsesAllocatable&&) - : d(2), a(static_cast(&a)) { } - - int d; - const void* a; -}; - -namespace std -{ - template<> - struct uses_allocator> : true_type { }; -} - -void uses_allocator_ctor() -{ - std::allocator a; - variant v(std::allocator_arg, a); - VERIFY(get<0>(v).d == 0); - VERIFY(get<0>(v).a == &a); - { - variant u(std::allocator_arg, a, v); - VERIFY(get<0>(u).d == 1); - VERIFY(get<0>(u).a == &a); - } - { - variant u(std::allocator_arg, a, std::move(v)); - VERIFY(get<0>(u).d == 2); - VERIFY(get<0>(u).a == &a); - } -} - void emplace() { variant v; @@ -450,7 +408,6 @@ int main() arbitrary_ctor(); in_place_index_ctor(); in_place_type_ctor(); - uses_allocator_ctor(); copy_assign(); move_assign(); arbitrary_assign();