+2016-08-15 Ville Voutilainen <ville.voutilainen@gmail.com>
+
+ Implement LWG 2744 and LWG 2754.
+ * include/std/any (any(ValueType&&)): Constrain with __is_in_place_type.
+ (any(in_place_type_t<_ValueType>, _Args&&...)): Use _Decay.
+ (any(in_place_type_t<_ValueType>, initializer_list<_Up>, _Args&&...)):
+ Likewise.
+ (emplace(_Args&&...)): Likewise.
+ (emplace(initializer_list<_Up>, _Args&&...)): Likewise.
+ * include/std/utility: (__is_in_place_type_impl): New.
+ (__is_in_place_type): Likewise.
+ * testsuite/20_util/any/assign/emplace.cc: Add tests for decaying
+ emplace.
+ * testsuite/20_util/any/cons/in_place.cc: Add tests for decaying
+ in_place constructor.
+ * testsuite/20_util/any/misc/any_cast_neg.cc: Adjust.
+ * testsuite/20_util/any/requirements.cc: Add a test for
+ in_place-constructing a non-default-constructible type.
+
2016-08-15 Ville Voutilainen <ville.voutilainen@gmail.com>
Add a feature macro for C++17 make_from_tuple.
/// Construct with a copy of @p __value as the contained object.
template <typename _ValueType, typename _Tp = _Decay<_ValueType>,
typename _Mgr = _Manager<_Tp>,
- __any_constructible_t<_Tp, _ValueType&&> = true>
+ __any_constructible_t<_Tp, _ValueType&&> = true,
+ enable_if_t<!__is_in_place_type<_ValueType>::value, bool> = true>
any(_ValueType&& __value)
: _M_manager(&_Mgr::_S_manage)
{
template <typename _ValueType, typename _Tp = _Decay<_ValueType>,
typename _Mgr = _Manager<_Tp>,
enable_if_t<__and_<is_copy_constructible<_Tp>,
- __not_<
- is_constructible<_Tp,
- _ValueType&&>>>::value,
+ __not_<is_constructible<_Tp, _ValueType&&>>,
+ __not_<__is_in_place_type<_ValueType>>>::value,
bool> = false>
any(_ValueType&& __value)
: _M_manager(&_Mgr::_S_manage)
}
/// Construct with an object created from @p __args as the contained object.
- template <typename _Tp, typename... _Args,
+ template <typename _ValueType, typename... _Args,
+ typename _Tp = _Decay<_ValueType>,
typename _Mgr = _Manager<_Tp>,
__any_constructible_t<_Tp, _Args&&...> = false>
- any(in_place_type_t<_Tp>, _Args&&... __args)
+ any(in_place_type_t<_ValueType>, _Args&&... __args)
: _M_manager(&_Mgr::_S_manage)
{
_Mgr::_S_create(_M_storage, std::forward<_Args>(__args)...);
/// Construct with an object created from @p __il and @p __args as
/// the contained object.
- template <typename _Tp, typename _Up, typename... _Args,
+ template <typename _ValueType, typename _Up, typename... _Args,
+ typename _Tp = _Decay<_ValueType>,
typename _Mgr = _Manager<_Tp>,
__any_constructible_t<_Tp, initializer_list<_Up>,
_Args&&...> = false>
- any(in_place_type_t<_Tp>, initializer_list<_Up> __il, _Args&&... __args)
+ any(in_place_type_t<_ValueType>,
+ initializer_list<_Up> __il, _Args&&... __args)
: _M_manager(&_Mgr::_S_manage)
{
_Mgr::_S_create(_M_storage, __il, std::forward<_Args>(__args)...);
}
/// Emplace with an object created from @p __args as the contained object.
- template <typename _Tp, typename... _Args,
+ template <typename _ValueType, typename... _Args,
+ typename _Tp = _Decay<_ValueType>,
typename _Mgr = _Manager<_Tp>,
__any_constructible_t<_Tp, _Args&&...> = false>
void emplace(_Args&&... __args)
/// Emplace with an object created from @p __il and @p __args as
/// the contained object.
- template <typename _Tp, typename _Up, typename... _Args,
+ template <typename _ValueType, typename _Up, typename... _Args,
+ typename _Tp = _Decay<_ValueType>,
typename _Mgr = _Manager<_Tp>,
__any_constructible_t<_Tp, initializer_list<_Up>,
_Args&&...> = false>