[libcxx-commits] [PATCH] D93590: [libc++] Implemented make_unique_for_overwrite
Ahmad Beirkdar via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Dec 19 22:27:06 PST 2020
ahmadbeirkdar created this revision.
ahmadbeirkdar added a reviewer: libc++.
ahmadbeirkdar added a project: libc++.
ahmadbeirkdar requested review of this revision.
Herald added a subscriber: libcxx-commits.
Herald added 1 blocking reviewer(s): libc++.
Implemented std::make_unique_for_overwrite according to the following paper: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1020r1.html
and the rename http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1973r1.pdf
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D93590
Files:
libcxx/include/memory
Index: libcxx/include/memory
===================================================================
--- libcxx/include/memory
+++ libcxx/include/memory
@@ -395,6 +395,10 @@
template<class T> unique_ptr<T> make_unique(size_t n); // C++14
template<class T, class... Args> unspecified make_unique(Args&&...) = delete; // C++14, T == U[N]
+template<class T> unique_ptr<T> make_unique_for_overwrite(); // C++20, T not an array
+template<class T> unique_ptr<T> make_unique_for_overwrite(size_t n); // C++20, T == U[]
+template<class T, class... Args> unspecified make_unique_for_overwrite(Args&&...) = delete; // C++20, T == U[N]
+
template<class E, class T, class Y, class D>
basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, unique_ptr<Y, D> const& p);
@@ -2074,6 +2078,31 @@
#endif // _LIBCPP_STD_VER > 11
+#if _LIBCPP_STD_VER > 20
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __unique_if<_Tp>::__unique_single
+make_unique_for_overwrite()
+{
+ return unique_ptr<_Tp>(new _Tp);;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __unique_if<_Tp>::__unique_array_unknown_bound
+make_unique_for_overwrite(size_t __n)
+{
+ typedef typename remove_extent<_Tp>::type _Up;
+ return unique_ptr<_Tp>(new _Up[__n]);
+}
+
+template<class _Tp, class... _Args>
+ typename __unique_if<_Tp>::__unique_array_known_bound
+ make_unique_for_overwrite(_Args&&...) = delete;
+
+#endif // _LIBCPP_STD_VER > 11
+
template <class _Tp, class _Dp>
#ifdef _LIBCPP_CXX03_LANG
struct _LIBCPP_TEMPLATE_VIS hash<unique_ptr<_Tp, _Dp> >
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93590.312958.patch
Type: text/x-patch
Size: 1672 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20201220/159763da/attachment.bin>
More information about the libcxx-commits
mailing list