From: Ville Voutilainen Date: Mon, 14 Nov 2016 20:47:44 +0000 (+0200) Subject: Implement P0504R0 (Revisiting in-place tag types for any/optional/variant). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=627a2f592382c96daaa3bce4a22245f0614892d0;p=gcc.git Implement P0504R0 (Revisiting in-place tag types for any/optional/variant). Implement P0504R0 (Revisiting in-place tag types for any/optional/variant). * include/std/any (any(_ValueType&& __value)): Constrain the __is_in_place_type with the decayed type. (make_any): Adjust to use the new tag type. * include/std/utility (in_place_tag): Remove. (in_place_t): Turn into a non-reference tag type. (__in_place, __in_place_type, __in_place_index): Remove. (in_place): Turn into an inline variable of non-reference tag type. (in_place<_Tp>): Remove. (in_place_index<_Idx>): Remove. (in_place_type_t): New. (in_place_type): Turn into a variable template of non-reference type. (in_place_index_t): New. (in_place_index): Turn into a variable template of non-reference type. * include/std/variant (_Variant_storage(in_place_index_t<_Np>, _Args&&...)): Adjust to use the new tag type. (_Union(in_place_index_t<0>, _Args&&...)): Likewise. (_Union(in_place_index_t<_Np>, _Args&&...)): Likewise. (_Variant_base()): Likewise. (variant(_Tp&&)): Likewise. (variant(in_place_type_t<_Tp>, _Args&&...)): Likewise. (variant(in_place_type_t<_Tp>, initializer_list<_Up>, _Args&&...)): Likewise. (variant(in_place_index_t<_Np>, _Args&&...)): Likewise. (variant(in_place_index_t<_Np>, initializer_list<_Up>, _Args&&...)): Likewise (variant(allocator_arg_t, const _Alloc&)): Likewise. (variant(allocator_arg_t, const _Alloc&, _Tp&&)): Likewise. (variant(allocator_arg_t, const _Alloc&, in_place_type_t<_Tp>, _Args&&...)): Likewise. (variant(allocator_arg_t, const _Alloc&, in_place_type_t<_Tp>, initializer_list<_Up>, _Args&&...)): Likewise. (variant(allocator_arg_t, const _Alloc&, in_place_index_t<_Np>, _Args&&...)): Likewise. (variant(allocator_arg_t, const _Alloc&, in_place_index_t<_Np>, initializer_list<_Up>, _Args&&...)): Likewise. (emplace(_Args&&...)): Likewise. (emplace(initializer_list<_Up>, _Args&&...)): Likewise. * testsuite/20_util/any/cons/explicit.cc: Likewise. * testsuite/20_util/any/cons/in_place.cc: Likewise. * testsuite/20_util/any/requirements.cc: Add tests to check that any is not constructible from the new in_place_type_t of any value category. * testsuite/20_util/in_place/requirements.cc: Adjust to use the new tag type. * testsuite/20_util/variant/compile.cc: Likewise. * testsuite/20_util/variant/run.cc: Likewise. From-SVN: r242401 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index e984dfbadfb..fd309713686 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,58 @@ +2016-11-14 Ville Voutilainen + + Implement P0504R0 (Revisiting in-place tag types for + any/optional/variant). + * include/std/any (any(_ValueType&& __value)): Constrain + the __is_in_place_type with the decayed type. + (make_any): Adjust to use the new tag type. + * include/std/utility (in_place_tag): Remove. + (in_place_t): Turn into a non-reference tag type. + (__in_place, __in_place_type, __in_place_index): Remove. + (in_place): Turn into an inline variable of non-reference + tag type. + (in_place<_Tp>): Remove. + (in_place_index<_Idx>): Remove. + (in_place_type_t): New. + (in_place_type): Turn into a variable template of non-reference + type. + (in_place_index_t): New. + (in_place_index): Turn into a variable template of non-reference + type. + * include/std/variant + (_Variant_storage(in_place_index_t<_Np>, _Args&&...)): Adjust to + use the new tag type. + (_Union(in_place_index_t<0>, _Args&&...)): Likewise. + (_Union(in_place_index_t<_Np>, _Args&&...)): Likewise. + (_Variant_base()): Likewise. + (variant(_Tp&&)): Likewise. + (variant(in_place_type_t<_Tp>, _Args&&...)): Likewise. + (variant(in_place_type_t<_Tp>, initializer_list<_Up>, + _Args&&...)): Likewise. + (variant(in_place_index_t<_Np>, _Args&&...)): Likewise. + (variant(in_place_index_t<_Np>, initializer_list<_Up>, + _Args&&...)): Likewise + (variant(allocator_arg_t, const _Alloc&)): Likewise. + (variant(allocator_arg_t, const _Alloc&, _Tp&&)): Likewise. + (variant(allocator_arg_t, const _Alloc&, in_place_type_t<_Tp>, + _Args&&...)): Likewise. + (variant(allocator_arg_t, const _Alloc&, in_place_type_t<_Tp>, + initializer_list<_Up>, _Args&&...)): Likewise. + (variant(allocator_arg_t, const _Alloc&, in_place_index_t<_Np>, + _Args&&...)): Likewise. + (variant(allocator_arg_t, const _Alloc&, in_place_index_t<_Np>, + initializer_list<_Up>, _Args&&...)): Likewise. + (emplace(_Args&&...)): Likewise. + (emplace(initializer_list<_Up>, _Args&&...)): Likewise. + * testsuite/20_util/any/cons/explicit.cc: Likewise. + * testsuite/20_util/any/cons/in_place.cc: Likewise. + * testsuite/20_util/any/requirements.cc: Add tests to + check that any is not constructible from the new in_place_type_t + of any value category. + * testsuite/20_util/in_place/requirements.cc: Adjust to + use the new tag type. + * testsuite/20_util/variant/compile.cc: Likewise. + * testsuite/20_util/variant/run.cc: Likewise. + 2016-11-14 Ville Voutilainen Use constexpr addressof in optional, SFINAE housekeeping diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any index 719e683f5ed..ded2bb27522 100644 --- a/libstdc++-v3/include/std/any +++ b/libstdc++-v3/include/std/any @@ -179,7 +179,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template , typename _Mgr = _Manager<_Tp>, __any_constructible_t<_Tp, _ValueType&&> = true, - enable_if_t::value, bool> = true> + enable_if_t::value, bool> = true> any(_ValueType&& __value) : _M_manager(&_Mgr::_S_manage) { @@ -191,7 +191,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename _Mgr = _Manager<_Tp>, enable_if_t<__and_, __not_>, - __not_<__is_in_place_type<_ValueType>>>::value, + __not_<__is_in_place_type<_Tp>>>::value, bool> = false> any(_ValueType&& __value) : _M_manager(&_Mgr::_S_manage) @@ -423,14 +423,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template any make_any(_Args&&... __args) { - return any(in_place<_Tp>, std::forward<_Args>(__args)...); + return any(in_place_type<_Tp>, std::forward<_Args>(__args)...); } /// Create an any holding a @c _Tp constructed from @c __il and @c __args. template any make_any(initializer_list<_Up> __il, _Args&&... __args) { - return any(in_place<_Tp>, __il, std::forward<_Args>(__args)...); + return any(in_place_type<_Tp>, __il, std::forward<_Args>(__args)...); } /** diff --git a/libstdc++-v3/include/std/utility b/libstdc++-v3/include/std/utility index 6a6659b5495..2ca52fe699a 100644 --- a/libstdc++-v3/include/std/utility +++ b/libstdc++-v3/include/std/utility @@ -336,25 +336,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus > 201402L - struct in_place_tag { - in_place_tag() = delete; + struct in_place_t { + explicit in_place_t() = default; }; - struct __in_place; - template struct __in_place_type; - template struct __in_place_index; - - using in_place_t = in_place_tag(&)(__in_place*); - template - using in_place_type_t = in_place_tag(&)(__in_place_type<_Tp>*); - template - using in_place_index_t = in_place_tag(&)(__in_place_index<_Idx>*); - - inline in_place_tag in_place(__in_place*) {terminate();} - template - in_place_tag in_place(__in_place_type<_Tp>*) {terminate();} - template - in_place_tag in_place(__in_place_index<_Idx>*) {terminate();} + inline constexpr in_place_t in_place{}; + + template struct in_place_type_t + { + explicit in_place_type_t() = default; + }; + + template + inline constexpr in_place_type_t<_Tp> in_place_type{}; + + template struct in_place_index_t + { + explicit in_place_index_t() = default; + }; + + template + inline constexpr in_place_index_t<_Idx> in_place_index{}; template struct __is_in_place_type_impl : false_type diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index 314f5f2f7f1..0d5fa56670b 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -302,7 +302,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template constexpr _Variant_storage(in_place_index_t<_Np>, _Args&&... __args) - : _M_union(in_place<_Np>, std::forward<_Args>(__args)...) + : _M_union(in_place_index<_Np>, std::forward<_Args>(__args)...) { } ~_Variant_storage() = default; @@ -320,13 +320,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template constexpr _Union(in_place_index_t<0>, _Args&&... __args) - : _M_first(in_place<0>, std::forward<_Args>(__args)...) + : _M_first(in_place_index<0>, std::forward<_Args>(__args)...) { } template> constexpr _Union(in_place_index_t<_Np>, _Args&&... __args) - : _M_rest(in_place<_Np - 1>, std::forward<_Args>(__args)...) + : _M_rest(in_place_index<_Np - 1>, std::forward<_Args>(__args)...) { } _Uninitialized<__storage<_First>> _M_first; @@ -361,7 +361,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Variant_base() noexcept(is_nothrow_default_constructible_v< variant_alternative_t<0, variant<_Types...>>>) - : _Variant_base(in_place<0>) { } + : _Variant_base(in_place_index<0>) { } _Variant_base(const _Variant_base& __rhs) : _Storage(), _M_index(__rhs._M_index) @@ -1018,7 +1018,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr variant(_Tp&& __t) noexcept(is_nothrow_constructible_v<__accepted_type<_Tp&&>, _Tp&&>) - : variant(in_place<__accepted_index<_Tp&&>>, std::forward<_Tp>(__t)) + : variant(in_place_index<__accepted_index<_Tp&&>>, std::forward<_Tp>(__t)) { __glibcxx_assert(holds_alternative<__accepted_type<_Tp&&>>(*this)); } template>> constexpr explicit variant(in_place_type_t<_Tp>, _Args&&... __args) - : variant(in_place<__index_of<_Tp>>, std::forward<_Args>(__args)...) + : variant(in_place_index<__index_of<_Tp>>, std::forward<_Args>(__args)...) { __glibcxx_assert(holds_alternative<_Tp>(*this)); } template, initializer_list<_Up> __il, _Args&&... __args) - : variant(in_place<__index_of<_Tp>>, __il, + : variant(in_place_index<__index_of<_Tp>>, __il, std::forward<_Args>(__args)...) { __glibcxx_assert(holds_alternative<_Tp>(*this)); } @@ -1045,7 +1045,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION is_constructible_v<__to_type<_Np>, _Args&&...>>> constexpr explicit variant(in_place_index_t<_Np>, _Args&&... __args) - : _Base(in_place<_Np>, std::forward<_Args>(__args)...), + : _Base(in_place_index<_Np>, std::forward<_Args>(__args)...), _Default_ctor_enabler(_Enable_default_constructor_tag{}) { __glibcxx_assert(index() == _Np); } @@ -1055,7 +1055,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr explicit variant(in_place_index_t<_Np>, initializer_list<_Up> __il, _Args&&... __args) - : _Base(in_place<_Np>, __il, std::forward<_Args>(__args)...), + : _Base(in_place_index<_Np>, __il, std::forward<_Args>(__args)...), _Default_ctor_enabler(_Enable_default_constructor_tag{}) { __glibcxx_assert(index() == _Np); } @@ -1063,7 +1063,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename = enable_if_t< __is_uses_allocator_constructible_v<__to_type<0>, _Alloc>>> variant(allocator_arg_t, const _Alloc& __a) - : variant(allocator_arg, __a, in_place<0>) + : variant(allocator_arg, __a, in_place_index<0>) { } template, _Alloc, _Tp&&> && !is_same_v, variant>, variant&>> variant(allocator_arg_t, const _Alloc& __a, _Tp&& __t) - : variant(allocator_arg, __a, in_place<__accepted_index<_Tp&&>>, + : variant(allocator_arg, __a, in_place_index<__accepted_index<_Tp&&>>, std::forward<_Tp>(__t)) { __glibcxx_assert(holds_alternative<__accepted_type<_Tp&&>>(*this)); } @@ -1102,7 +1102,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tp, _Alloc, _Args&&...>>> variant(allocator_arg_t, const _Alloc& __a, in_place_type_t<_Tp>, _Args&&... __args) - : variant(allocator_arg, __a, in_place<__index_of<_Tp>>, + : variant(allocator_arg, __a, in_place_index<__index_of<_Tp>>, std::forward<_Args>(__args)...) { __glibcxx_assert(holds_alternative<_Tp>(*this)); } @@ -1113,7 +1113,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _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_of<_Tp>>, __il, + : variant(allocator_arg, __a, in_place_index<__index_of<_Tp>>, __il, std::forward<_Args>(__args)...) { __glibcxx_assert(holds_alternative<_Tp>(*this)); } @@ -1123,7 +1123,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __to_type<_Np>, _Alloc, _Args&&...>>> variant(allocator_arg_t, const _Alloc& __a, in_place_index_t<_Np>, _Args&&... __args) - : _Base(__a, in_place<_Np>, std::forward<_Args>(__args)...), + : _Base(__a, in_place_index<_Np>, std::forward<_Args>(__args)...), _Default_ctor_enabler(_Enable_default_constructor_tag{}) { __glibcxx_assert(index() == _Np); } @@ -1133,7 +1133,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __to_type<_Np>, _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<_Np>, __il, std::forward<_Args>(__args)...), + : _Base(__a, in_place_index<_Np>, __il, std::forward<_Args>(__args)...), _Default_ctor_enabler(_Enable_default_constructor_tag{}) { __glibcxx_assert(index() == _Np); } @@ -1188,7 +1188,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION this->~variant(); __try { - ::new (this) variant(in_place<_Np>, + ::new (this) variant(in_place_index<_Np>, std::forward<_Args>(__args)...); } __catch (...) @@ -1207,7 +1207,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION this->~variant(); __try { - ::new (this) variant(in_place<_Np>, __il, + ::new (this) variant(in_place_index<_Np>, __il, std::forward<_Args>(__args)...); } __catch (...) diff --git a/libstdc++-v3/testsuite/20_util/any/cons/explicit.cc b/libstdc++-v3/testsuite/20_util/any/cons/explicit.cc index 61d50359a34..f0d64dbe3c7 100644 --- a/libstdc++-v3/testsuite/20_util/any/cons/explicit.cc +++ b/libstdc++-v3/testsuite/20_util/any/cons/explicit.cc @@ -24,7 +24,7 @@ int main() { - std::any a = {std::in_place, 42}; // { dg-error "converting" } - std::any a2 = - {std::in_place>, {42, 666}}; // { dg-error "converting" } + std::any a = {std::in_place_type, 42}; // { dg-error "converting" } + std::any a2 = {std::in_place_type>, + {42, 666}}; // { dg-error "converting" } } diff --git a/libstdc++-v3/testsuite/20_util/any/cons/in_place.cc b/libstdc++-v3/testsuite/20_util/any/cons/in_place.cc index 52f2b38d5fc..374a10a61fa 100644 --- a/libstdc++-v3/testsuite/20_util/any/cons/in_place.cc +++ b/libstdc++-v3/testsuite/20_util/any/cons/in_place.cc @@ -36,30 +36,30 @@ struct combined { int main() { const int i = 42; - std::any o(std::in_place, i); + std::any o(std::in_place_type, i); int& i2 = std::any_cast(o); VERIFY( i2 == 42 ); VERIFY( &i2 != &i ); - std::any o2(std::in_place>, 1, 2); + std::any o2(std::in_place_type>, 1, 2); std::tuple& t = std::any_cast&>(o2); VERIFY( std::get<0>(t) == 1 && std::get<1>(t) == 2); - std::any o3(std::in_place>, {42, 666}); + std::any o3(std::in_place_type>, {42, 666}); std::vector& v = std::any_cast&>(o3); VERIFY(v[0] == 42 && v[1] == 666); - std::any o4(std::in_place, {42, 666}); + std::any o4(std::in_place_type, {42, 666}); combined& c = std::any_cast(o4); VERIFY(c.v[0] == 42 && c.v[1] == 666 && std::get<0>(c.t) == 0 && std::get<1>(c.t) == 0 ); - std::any o5(std::in_place, {1, 2}, 3, 4); + std::any o5(std::in_place_type, {1, 2}, 3, 4); combined& c2 = std::any_cast(o5); VERIFY(c2.v[0] == 1 && c2.v[1] == 2 && std::get<0>(c2.t) == 3 && std::get<1>(c2.t) == 4 ); - std::any o6(std::in_place, i); + std::any o6(std::in_place_type, i); VERIFY(o6.type() == o.type()); - std::any o7(std::in_place, nullptr); - std::any o8(std::in_place, nullptr); + std::any o7(std::in_place_type, nullptr); + std::any o8(std::in_place_type, nullptr); VERIFY(o7.type() == o8.type()); - std::any o9(std::in_place, nullptr); - std::any o10(std::in_place, nullptr); + std::any o9(std::in_place_type, nullptr); + std::any o10(std::in_place_type, nullptr); VERIFY(o9.type() == o10.type()); } diff --git a/libstdc++-v3/testsuite/20_util/any/requirements.cc b/libstdc++-v3/testsuite/20_util/any/requirements.cc index 7b084bec64a..80ab2a630f1 100644 --- a/libstdc++-v3/testsuite/20_util/any/requirements.cc +++ b/libstdc++-v3/testsuite/20_util/any/requirements.cc @@ -42,3 +42,15 @@ struct NoDefaultCtor static_assert(!std::is_constructible>::value); + +static_assert(!std::is_constructible&>::value); + +static_assert(!std::is_constructible&&>::value); + +static_assert(!std::is_constructible&>::value); + +static_assert(!std::is_constructible&&>::value); diff --git a/libstdc++-v3/testsuite/20_util/in_place/requirements.cc b/libstdc++-v3/testsuite/20_util/in_place/requirements.cc index fc141d862fd..a31a1533ee8 100644 --- a/libstdc++-v3/testsuite/20_util/in_place/requirements.cc +++ b/libstdc++-v3/testsuite/20_util/in_place/requirements.cc @@ -32,16 +32,21 @@ char f(in_place_index_t<0>); unsigned int f(in_place_index_t<1>); int f(in_place_t); -static_assert(std::is_same::value); -static_assert(std::is_same)), float>::value); -static_assert(std::is_same)), double>::value); -static_assert(std::is_same)), char>::value); -static_assert(std::is_same)), unsigned int>::value); +static_assert(std::is_same::value); +static_assert(std::is_same)), + float>::value); +static_assert(std::is_same)), + double>::value); +static_assert(std::is_same)), char>::value); +static_assert(std::is_same)), + unsigned int>::value); template float h(in_place_type_t, Args&&...); template int h(in_place_index_t, Args&&...); template double h(in_place_t, T&&); static_assert(std::is_same::value); -static_assert(std::is_same, 1)), float>::value); -static_assert(std::is_same, 1)), int>::value); +static_assert(std::is_same, 1)), + float>::value); +static_assert(std::is_same, 1)), + int>::value); diff --git a/libstdc++-v3/testsuite/20_util/variant/compile.cc b/libstdc++-v3/testsuite/20_util/variant/compile.cc index 4016d9e2c7d..08de71e7cce 100644 --- a/libstdc++-v3/testsuite/20_util/variant/compile.cc +++ b/libstdc++-v3/testsuite/20_util/variant/compile.cc @@ -107,14 +107,14 @@ void arbitrary_ctor() void in_place_index_ctor() { - variant a(in_place<0>, "a"); - variant b(in_place<1>, {'a'}); + variant a(in_place_index<0>, "a"); + variant b(in_place_index<1>, {'a'}); } void in_place_type_ctor() { - variant a(in_place, "a"); - variant b(in_place, {'a'}); + variant a(in_place_type, "a"); + variant b(in_place_type, {'a'}); static_assert(!is_constructible_v, in_place_type_t, const char*>, ""); } @@ -136,18 +136,18 @@ void uses_alloc_ctors() static_assert(!is_constructible_v, allocator_arg_t, std::allocator, const char*>, ""); } { - variant b(allocator_arg, alloc, in_place<0>, "a"); - variant c(allocator_arg, alloc, in_place<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<0>, {'a'}); - variant c(allocator_arg, alloc, in_place<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, "a"); + variant b(allocator_arg, alloc, in_place_type, "a"); } { - variant b(allocator_arg, alloc, in_place, {'a'}); + variant b(allocator_arg, alloc, in_place_type, {'a'}); } } @@ -371,13 +371,13 @@ void test_constexpr() { constexpr variant a; static_assert(holds_alternative(a), ""); - constexpr variant b(in_place<0>, int{}); + constexpr variant b(in_place_index<0>, int{}); static_assert(holds_alternative(b), ""); - constexpr variant c(in_place, int{}); + constexpr variant c(in_place_type, int{}); static_assert(holds_alternative(c), ""); - constexpr variant d(in_place<1>, char{}); + constexpr variant d(in_place_index<1>, char{}); static_assert(holds_alternative(d), ""); - constexpr variant e(in_place, char{}); + constexpr variant e(in_place_type, char{}); static_assert(holds_alternative(e), ""); constexpr variant f(char{}); static_assert(holds_alternative(f), ""); @@ -392,8 +392,8 @@ void test_constexpr() }; constexpr variant v{}; - constexpr variant v1{in_place}; - constexpr variant v2{in_place<0>}; + constexpr variant v1{in_place_type}; + constexpr variant v2{in_place_index<0>}; } } @@ -448,20 +448,20 @@ void test_adl() v0.emplace<0>(x); v0.emplace<0>(il, x); visit(vis, v0); - variant v1{in_place<0>, x}; - variant v2{in_place, x}; - variant v3{in_place<0>, il, x}; - variant v4{in_place, il, x}; - variant v5{allocator_arg, a, in_place<0>, x}; - variant v6{allocator_arg, a, in_place, x}; - variant v7{allocator_arg, a, in_place<0>, il, x}; - variant v8{allocator_arg, a, in_place, il, x}; - variant v9{allocator_arg, a, in_place, 1}; + variant v1{in_place_index<0>, x}; + 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}; std::variant vr0(x); vr0 = x; - variant vr1{in_place<0>, x}; - variant vr2{in_place, x}; - variant vr3{allocator_arg, a, in_place<0>, x}; - variant vr4{allocator_arg, a, in_place, x}; + variant vr1{in_place_index<0>, x}; + variant vr2{in_place_type, x}; + variant vr3{allocator_arg, a, in_place_index<0>, x}; + variant vr4{allocator_arg, a, in_place_type, x}; } diff --git a/libstdc++-v3/testsuite/20_util/variant/run.cc b/libstdc++-v3/testsuite/20_util/variant/run.cc index 3a952221d4e..71e01767ff6 100644 --- a/libstdc++-v3/testsuite/20_util/variant/run.cc +++ b/libstdc++-v3/testsuite/20_util/variant/run.cc @@ -122,12 +122,12 @@ void dtor() }; { int called = 0; - { variant a(in_place<1>, called); } + { variant a(in_place_index<1>, called); } VERIFY(called == 1); } { int called = 0; - { variant a(in_place<0>); } + { variant a(in_place_index<0>); } VERIFY(called == 0); } } @@ -135,12 +135,12 @@ void dtor() void in_place_index_ctor() { { - variant v(in_place<1>, "a"); + variant v(in_place_index<1>, "a"); VERIFY(holds_alternative(v)); VERIFY(get<1>(v) == "a"); } { - variant v(in_place<1>, {'a', 'b'}); + variant v(in_place_index<1>, {'a', 'b'}); VERIFY(holds_alternative(v)); VERIFY(get<1>(v) == "ab"); } @@ -149,12 +149,12 @@ void in_place_index_ctor() void in_place_type_ctor() { { - variant v(in_place, "a"); + variant v(in_place_type, "a"); VERIFY(holds_alternative(v)); VERIFY(get<1>(v) == "a"); } { - variant v(in_place, {'a', 'b'}); + variant v(in_place_type, {'a', 'b'}); VERIFY(holds_alternative(v)); VERIFY(get<1>(v) == "ab"); }