summaryrefslogtreecommitdiff
path: root/include/any
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-04-16 16:03:23 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-04-16 16:03:23 +0000
commit0dc0969cd0a732760f0aa79942a04e0eaef297c4 (patch)
tree051bdb57b1ac6ee143f61ddbb47bd0da619f6f0c /include/any
parent868847c6900e575417c03bced6e562b3af891318 (diff)
downloadsrc-test2-0dc0969cd0a732760f0aa79942a04e0eaef297c4.tar.gz
src-test2-0dc0969cd0a732760f0aa79942a04e0eaef297c4.zip
Notes
Diffstat (limited to 'include/any')
-rw-r--r--include/any28
1 files changed, 16 insertions, 12 deletions
diff --git a/include/any b/include/any
index 823e1304b5cc..d7161b0d6f4c 100644
--- a/include/any
+++ b/include/any
@@ -45,6 +45,10 @@ namespace std {
any& operator=(ValueType&& rhs);
// 6.3.3 any modifiers
+ template <class ValueType, class... Args>
+ decay_t<ValueType>& emplace(Args&&... args);
+ template <class ValueType, class U, class... Args>
+ decay_t<ValueType>& emplace(initializer_list<U>, Args&&...);
void reset() noexcept;
void swap(any& rhs) noexcept;
@@ -73,8 +77,6 @@ namespace std {
template<class ValueType>
ValueType* any_cast(any* operand) noexcept;
-} // namespace fundamentals_v1
-} // namespace experimental
} // namespace std
*/
@@ -258,7 +260,7 @@ public:
is_copy_constructible<_Tp>::value>
>
_LIBCPP_INLINE_VISIBILITY
- void emplace(_Args&&... args);
+ _Tp& emplace(_Args&&... args);
template <class _ValueType, class _Up, class ..._Args,
class _Tp = decay_t<_ValueType>,
@@ -267,7 +269,7 @@ public:
is_copy_constructible<_Tp>::value>
>
_LIBCPP_INLINE_VISIBILITY
- void emplace(initializer_list<_Up>, _Args&&...);
+ _Tp& emplace(initializer_list<_Up>, _Args&&...);
// 6.3.3 any modifiers
_LIBCPP_INLINE_VISIBILITY
@@ -364,9 +366,10 @@ namespace __any_imp
template <class ..._Args>
_LIBCPP_INLINE_VISIBILITY
- static void __create(any & __dest, _Args&&... __args) {
- ::new (static_cast<void*>(&__dest.__s.__buf)) _Tp(_VSTD::forward<_Args>(__args)...);
+ static _Tp& __create(any & __dest, _Args&&... __args) {
+ _Tp* __ret = ::new (static_cast<void*>(&__dest.__s.__buf)) _Tp(_VSTD::forward<_Args>(__args)...);
__dest.__h = &_SmallHandler::__handle;
+ return *__ret;
}
private:
@@ -439,14 +442,15 @@ namespace __any_imp
template <class ..._Args>
_LIBCPP_INLINE_VISIBILITY
- static void __create(any & __dest, _Args&&... __args) {
+ static _Tp& __create(any & __dest, _Args&&... __args) {
typedef allocator<_Tp> _Alloc;
typedef __allocator_destructor<_Alloc> _Dp;
_Alloc __a;
unique_ptr<_Tp, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new ((void*)__hold.get()) _Tp(_VSTD::forward<_Args>(__args)...);
+ _Tp* __ret = ::new ((void*)__hold.get()) _Tp(_VSTD::forward<_Args>(__args)...);
__dest.__s.__ptr = __hold.release();
__dest.__h = &_LargeHandler::__handle;
+ return *__ret;
}
private:
@@ -519,16 +523,16 @@ any & any::operator=(_ValueType && __v)
template <class _ValueType, class ..._Args, class _Tp, class>
inline _LIBCPP_INLINE_VISIBILITY
-void any::emplace(_Args&&... __args) {
+_Tp& any::emplace(_Args&&... __args) {
reset();
- __any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_Args>(__args)...);
+ return __any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_Args>(__args)...);
}
template <class _ValueType, class _Up, class ..._Args, class _Tp, class>
inline _LIBCPP_INLINE_VISIBILITY
-void any::emplace(initializer_list<_Up> __il, _Args&&... __args) {
+_Tp& any::emplace(initializer_list<_Up> __il, _Args&&... __args) {
reset();
- __any_imp::_Handler<_Tp>::__create(*this, __il, _VSTD::forward<_Args>(__args)...);
+ return __any_imp::_Handler<_Tp>::__create(*this, __il, _VSTD::forward<_Args>(__args)...);
}
inline _LIBCPP_INLINE_VISIBILITY