+2016-12-29 Ville Voutilainen <ville.voutilainen@gmail.com>
+
+ 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.
+
2016-12-24 François Dumont <fdumont@gcc.gnu.org>
* include/ext/random.tcc: Fix usage of _OutputIteratorConcept.
: _Optional_base{} { }
// Constructors for engaged optionals.
- template<typename... _Args>
+ template<typename... _Args,
+ enable_if_t<is_constructible_v<_Tp, _Args&&...>, bool> = false>
constexpr explicit _Optional_base(in_place_t, _Args&&... __args)
: _M_payload(std::forward<_Args>(__args)...), _M_engaged(true) { }
template<typename _Up, typename... _Args,
- enable_if_t<is_constructible<_Tp,
- initializer_list<_Up>&,
- _Args&&...>::value,
- int>...>
+ enable_if_t<is_constructible_v<_Tp,
+ initializer_list<_Up>&,
+ _Args&&...>, bool> = false>
constexpr explicit _Optional_base(in_place_t,
initializer_list<_Up> __il,
_Args&&... __args)
constexpr _Optional_base(nullopt_t) noexcept
: _Optional_base{} { }
- template<typename... _Args>
+ template<typename... _Args,
+ enable_if_t<is_constructible_v<_Tp, _Args&&...>, bool> = false>
constexpr explicit _Optional_base(in_place_t, _Args&&... __args)
: _M_payload(std::forward<_Args>(__args)...), _M_engaged(true) { }
template<typename _Up, typename... _Args,
- enable_if_t<is_constructible<_Tp,
- initializer_list<_Up>&,
- _Args&&...>::value,
- int>...>
+ enable_if_t<is_constructible_v<_Tp,
+ initializer_list<_Up>&,
+ _Args&&...>, bool> = false>
constexpr explicit _Optional_base(in_place_t,
initializer_list<_Up> __il,
_Args&&... __args)
template <typename _Up = _Tp,
enable_if_t<__and_<
__not_<is_same<optional<_Tp>, decay_t<_Up>>>,
+ __not_<is_same<in_place_t, decay_t<_Up>>>,
is_constructible<_Tp, _Up&&>,
is_convertible<_Up&&, _Tp>
>::value, bool> = true>
template <typename _Up = _Tp,
enable_if_t<__and_<
__not_<is_same<optional<_Tp>, decay_t<_Up>>>,
+ __not_<is_same<in_place_t, decay_t<_Up>>>,
is_constructible<_Tp, _Up&&>,
__not_<is_convertible<_Up&&, _Tp>>
>::value, bool> = false>
emplace(std::move(*__t));
}
- template<typename... _Args>
+ template<typename... _Args,
+ enable_if_t<is_constructible_v<_Tp, _Args&&...>, bool> = false>
explicit constexpr optional(in_place_t, _Args&&... __args)
: _Base(std::in_place, std::forward<_Args>(__args)...) { }
template<typename _Up, typename... _Args,
- enable_if_t<is_constructible<_Tp,
- initializer_list<_Up>&,
- _Args&&...>::value,
- int>...>
+ enable_if_t<is_constructible_v<_Tp,
+ initializer_list<_Up>&,
+ _Args&&...>, bool> = false>
explicit constexpr optional(in_place_t,
initializer_list<_Up> __il,
_Args&&... __args)