From 2ae2d394c1f9928fcb4bb7efdf9874edb787936a Mon Sep 17 00:00:00 2001 From: Ville Voutilainen Date: Thu, 29 Dec 2016 21:19:59 +0200 Subject: Implement LWG 2842, in_place_t check for optional::optional(U&&) should decay U. Implement LWG 2842, in_place_t check for optional::optional(U&&) should decay U. * include/std/optional (_Optional_base(in_place_t, _Args&&...)): Constrain. (_Optional_base(in_place_t, initializer_list<_Up>, _Args&&...)): Turn the int-pack constraint hack into a saner bool. (_Optional_base<_Tp, false>::_Optional_base(in_place_t, _Args&&...)): Constrain. (_Optional_base<_Tp, false>::_Optional_base(in_place_t, initializer_list<_Up>, _Args&&...)): Turn the int-pack constraint hack into a saner bool. (optional(_Up&&)): Constrain against in_place_t. (optional(in_place_t, _Args&&...)): Constrain. (constexpr optional(in_place_t, initializer_list<_Up>, _Args&&...)): Turn the int-pack constraint hack into a saner bool. * testsuite/20_util/optional/cons/value_neg.cc: Add a test for a type that is constructible from in_place. From-SVN: r243966 --- libstdc++-v3/include/std/optional | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'libstdc++-v3/include/std') diff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional index 3d69e10..73bc2b4 100644 --- a/libstdc++-v3/include/std/optional +++ b/libstdc++-v3/include/std/optional @@ -128,15 +128,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : _Optional_base{} { } // Constructors for engaged optionals. - template + template, bool> = false> constexpr explicit _Optional_base(in_place_t, _Args&&... __args) : _M_payload(std::forward<_Args>(__args)...), _M_engaged(true) { } template&, - _Args&&...>::value, - int>...> + enable_if_t&, + _Args&&...>, bool> = false> constexpr explicit _Optional_base(in_place_t, initializer_list<_Up> __il, _Args&&... __args) @@ -264,15 +264,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION constexpr _Optional_base(nullopt_t) noexcept : _Optional_base{} { } - template + template, bool> = false> constexpr explicit _Optional_base(in_place_t, _Args&&... __args) : _M_payload(std::forward<_Args>(__args)...), _M_engaged(true) { } template&, - _Args&&...>::value, - int>...> + enable_if_t&, + _Args&&...>, bool> = false> constexpr explicit _Optional_base(in_place_t, initializer_list<_Up> __il, _Args&&... __args) @@ -432,6 +432,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template , decay_t<_Up>>>, + __not_>>, is_constructible<_Tp, _Up&&>, is_convertible<_Up&&, _Tp> >::value, bool> = true> @@ -441,6 +442,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template , decay_t<_Up>>>, + __not_>>, is_constructible<_Tp, _Up&&>, __not_> >::value, bool> = false> @@ -499,15 +501,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION emplace(std::move(*__t)); } - template + template, bool> = false> explicit constexpr optional(in_place_t, _Args&&... __args) : _Base(std::in_place, std::forward<_Args>(__args)...) { } template&, - _Args&&...>::value, - int>...> + enable_if_t&, + _Args&&...>, bool> = false> explicit constexpr optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args) -- cgit v1.1