[libcxx-commits] [PATCH] D152208: [libc++] Introduce __uninitialized_buffer and use it instead of get_temporary_buffer
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jun 6 10:33:46 PDT 2023
Mordante added a comment.
Would it make sense to add some internal tests for this class?
================
Comment at: libcxx/include/__algorithm/stable_partition.h:19
#include <__memory/destruct_n.h>
#include <__memory/temporary_buffer.h>
+#include <__memory/uninitialized_buffer.h>
----------------
Can this be removed?
================
Comment at: libcxx/include/__algorithm/stable_partition.h:143
{
-// TODO: Remove the use of std::get_temporary_buffer
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
- __p = _VSTD::get_temporary_buffer<value_type>(__len);
-_LIBCPP_SUPPRESS_DEPRECATED_POP
- __h.reset(__p.first);
+ __uninitialized_buffer<value_type, __destruct::__never> __buf(__len);
+ return std::__stable_partition_impl<_AlgPolicy, _Predicate&>(
----------------
Is never correct when the type does things in its destructor?
Or are all elements in a moved from state?
================
Comment at: libcxx/include/__memory/construct_at.h:99
+_ForwardIterator __destroy_n(_ForwardIterator __first, _Size __n) {
+ for (; __n > 0; (void)++__first, --__n)
+ std::__destroy_at(std::addressof(*__first));
----------------
================
Comment at: libcxx/include/__memory/uninitialized_buffer.h:34
+#ifdef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+ _LIBCPP_HIDE_FROM_ABI __uninitialized_buffer(size_type __count)
+ : __data_(static_cast<_Tp*>(::operator new(sizeof(_Tp) * __count))), __count_(__count) {}
----------------
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152208/new/
https://reviews.llvm.org/D152208
More information about the libcxx-commits
mailing list