[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:56:12 PST 2020
ahmadbeirkdar updated this revision to Diff 312959.
ahmadbeirkdar added a comment.
Typo in _LIBCPP_STD_VER check, and an extra semi colon.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93590/new/
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 >= 20
+
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.312959.patch
Type: text/x-patch
Size: 1673 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20201220/f5473b0f/attachment.bin>
More information about the libcxx-commits
mailing list