summaryrefslogtreecommitdiff
path: root/include/memory
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2016-07-11 21:38:08 +0000
committerMarshall Clow <mclow.lists@gmail.com>2016-07-11 21:38:08 +0000
commit51d7e8e38165ba367882161b9b7f88e7255c65aa (patch)
treeea77ffe21c464768dbcb8cf54590307b1d69dad9 /include/memory
parent45e9a936b64ee13890c95c9e809897e58fe668c9 (diff)
Always use the allocator to construct/destruct elements of a deque/vector. Fixes PR#28412. Thanks to Jonathan Wakely for the report.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@275105 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/memory')
-rw-r--r--include/memory20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/memory b/include/memory
index 50a1f00a5..7a3281e17 100644
--- a/include/memory
+++ b/include/memory
@@ -5674,6 +5674,26 @@ struct __noexcept_move_assign_container : public integral_constant<bool,
#endif
> {};
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+template <class _Tp, class _Alloc>
+struct __temp_value {
+ typedef allocator_traits<_Alloc> _Traits;
+
+ typename aligned_storage<sizeof(_Tp), alignof(_Tp)>::type __v;
+ _Alloc &__a;
+
+ _Tp *__addr() { return reinterpret_cast<_Tp *>(addressof(__v)); }
+ _Tp & get() { return *__addr(); }
+
+ template<class... _Args>
+ __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc)
+ { _Traits::construct(__a, __addr(), _VSTD::forward<_Args>(__args)...); }
+
+ ~__temp_value() { _Traits::destroy(__a, __addr()); }
+ };
+#endif
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_MEMORY