Title: [201258] trunk/Source/WTF
Revision
201258
Author
m...@apple.com
Date
2016-05-22 15:19:33 -0700 (Sun, 22 May 2016)

Log Message

Additional fixes for non-C++14 Apple projects that use WTF.

* wtf/StdLibExtras.h:
(std::make_unique):
(std::move):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (201257 => 201258)


--- trunk/Source/WTF/ChangeLog	2016-05-22 22:04:10 UTC (rev 201257)
+++ trunk/Source/WTF/ChangeLog	2016-05-22 22:19:33 UTC (rev 201258)
@@ -1,5 +1,13 @@
 2016-05-22  Dan Bernstein  <m...@apple.com>
 
+        Additional fixes for non-C++14 Apple projects that use WTF.
+
+        * wtf/StdLibExtras.h:
+        (std::make_unique):
+        (std::move):
+
+2016-05-22  Dan Bernstein  <m...@apple.com>
+
         Correct the previous build fix attempt.
 
         * wtf/StdLibExtras.h:

Modified: trunk/Source/WTF/wtf/StdLibExtras.h (201257 => 201258)


--- trunk/Source/WTF/wtf/StdLibExtras.h	2016-05-22 22:04:10 UTC (rev 201257)
+++ trunk/Source/WTF/wtf/StdLibExtras.h	2016-05-22 22:19:33 UTC (rev 201258)
@@ -320,7 +320,36 @@
 
 // This adds various C++14 features for versions of the STL that may not yet have them.
 namespace std {
+#if __cplusplus < 201400L
+template<class T> struct _Unique_if {
+    typedef unique_ptr<T> _Single_object;
+};
 
+template<class T> struct _Unique_if<T[]> {
+    typedef unique_ptr<T[]> _Unknown_bound;
+};
+
+template<class T, size_t N> struct _Unique_if<T[N]> {
+    typedef void _Known_bound;
+};
+
+template<class T, class... Args> inline typename _Unique_if<T>::_Single_object
+make_unique(Args&&... args)
+{
+    return unique_ptr<T>(new T(std::forward<Args>(args)...));
+}
+
+template<class T> inline typename _Unique_if<T>::_Unknown_bound
+make_unique(size_t n)
+{
+    typedef typename remove_extent<T>::type U;
+    return unique_ptr<T>(new U[n]());
+}
+
+template<class T, class... Args> typename _Unique_if<T>::_Known_bound
+make_unique(Args&&...) = delete;
+#endif
+
 template<WTF::CheckMoveParameterTag, typename T>
 ALWAYS_INLINE constexpr typename remove_reference<T>::type&& move(T&& value)
 {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to