[v3 PATCH] Implement P0040R3, Extending memory management tools.

Jonathan Wakely jwakely@redhat.com
Tue Sep 13 08:16:00 GMT 2016


On 13/09/16 00:59 +0300, Ville Voutilainen wrote:
>@@ -682,6 +686,98 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> 					 std::__iterator_category(__first)); }
> #endif
>
>+#if __cplusplus > 201402L
>+  template <typename _ForwardIterator>
>+    inline void
>+    uninitialized_default_construct(_ForwardIterator __first,
>+				    _ForwardIterator __last)
>+  {
>+    for (; __first != __last; ++__first)
>+      ::new (static_cast<void*>(std::__addressof(*__first)))
>+	  typename iterator_traits<_ForwardIterator>::value_type;
>+  }

The bodies of all these function templates should be indented another
two spaces, to line up with the function name.

>+  template <typename _Tp>
>+    inline void
>+    destroy_at(_Tp* __location)
>+  {
>+    __location->~_Tp();
>+  }

This is now the third function template we've added recently doing
this :-) (although the ones in <variant> and <bits/exception_ptr.h>
have void* parameters).

>+  template <typename _ForwardIterator>
>+    inline void
>+    destroy(_ForwardIterator __first, _ForwardIterator __last)
>+  {
>+    for (; __first != __last; ++__first)
>+      destroy_at(std::__addressof(*__first));

This needs to be std::destroy_at

>+  }
>+
>+  template <typename _ForwardIterator, typename _Size>
>+    inline _ForwardIterator
>+    destroy_n(_ForwardIterator __first, _Size __count)
>+  {
>+    for (; __count > 0; (void)++__first, --__count)
>+      destroy_at(std::__addressof(*__first));

Ditto.

OK with those changes, thanks.



More information about the Libstdc++ mailing list