[libcxx] r222138 - Implement void_t from N3911. Add a private version for use in the library before C++1z. Update the 1z status page, marking a bunch of issues that don't require library changes as complete (2129, 2212, 2230, 2233, 2325, 2365, 2376)

Marshall Clow mclow.lists at gmail.com
Mon Nov 17 07:50:08 PST 2014


Author: marshall
Date: Mon Nov 17 09:50:08 2014
New Revision: 222138

URL: http://llvm.org/viewvc/llvm-project?rev=222138&view=rev
Log:
Implement void_t from N3911. Add a private version for use in the library before C++1z. Update the 1z status page, marking a bunch of issues that don't require library changes as complete (2129, 2212, 2230, 2233, 2325, 2365, 2376)

Added:
    libcxx/trunk/test/utilities/meta/meta.unary.prop.query/void_t.pass.cpp
Modified:
    libcxx/trunk/include/type_traits
    libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/type_traits
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=222138&r1=222137&r2=222138&view=diff
==============================================================================
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Mon Nov 17 09:50:08 2014
@@ -197,7 +197,9 @@ namespace std
     template <class F, class... ArgTypes>
       using result_of_t       = typename result_of<F(ArgTypes...)>::type;  // C++14
 
-}  // std
+    template <class...>
+      using void_t = void;
+}  // C++17
 
 */
 #include <__config>
@@ -209,6 +211,11 @@ namespace std
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+template <class...> 
+struct __void_t { typedef void type; };
+#endif
+
 template <bool _Bp, class _If, class _Then>
     struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;};
 template <class _If, class _Then>
@@ -3673,6 +3680,10 @@ struct __has_operator_addressof
 
 #endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
 
+#if _LIBCPP_STD_VER > 14
+template <class...> using void_t = void;
+#endif
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_TYPE_TRAITS

Added: libcxx/trunk/test/utilities/meta/meta.unary.prop.query/void_t.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/meta/meta.unary.prop.query/void_t.pass.cpp?rev=222138&view=auto
==============================================================================
--- libcxx/trunk/test/utilities/meta/meta.unary.prop.query/void_t.pass.cpp (added)
+++ libcxx/trunk/test/utilities/meta/meta.unary.prop.query/void_t.pass.cpp Mon Nov 17 09:50:08 2014
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// void_t
+
+#include <type_traits>
+
+#if _LIBCPP_STD_VER <= 14
+int main () {}
+#else
+
+template <class T>
+void test1()
+{
+    static_assert( std::is_same<void, std::void_t<T>>::value, "");
+    static_assert( std::is_same<void, std::void_t<const T>>::value, "");
+    static_assert( std::is_same<void, std::void_t<volatile T>>::value, "");
+    static_assert( std::is_same<void, std::void_t<const volatile T>>::value, "");
+}
+
+template <class T, class U>
+void test2()
+{
+    static_assert( std::is_same<void, std::void_t<T, U>>::value, "");
+    static_assert( std::is_same<void, std::void_t<const T, U>>::value, "");
+    static_assert( std::is_same<void, std::void_t<volatile T, U>>::value, "");
+    static_assert( std::is_same<void, std::void_t<const volatile T, U>>::value, "");
+
+    static_assert( std::is_same<void, std::void_t<T, const U>>::value, "");
+    static_assert( std::is_same<void, std::void_t<const T, const U>>::value, "");
+    static_assert( std::is_same<void, std::void_t<volatile T, const U>>::value, "");
+    static_assert( std::is_same<void, std::void_t<const volatile T, const U>>::value, "");
+}
+
+class Class
+{
+public:
+    ~Class();
+};
+
+int main()
+{
+    static_assert( std::is_same<void, std::void_t<>>::value, "");
+
+	test1<void>();
+	test1<int>();
+	test1<double>();
+	test1<int&>();
+	test1<Class>();
+	test1<Class[]>();
+	test1<Class[5]>();
+	
+	test2<void, int>();
+	test2<double, int>();
+	test2<int&, int>();
+	test2<Class&, bool>();
+	test2<void *, int&>();
+
+    static_assert( std::is_same<void, std::void_t<int, double const &, Class, volatile int[], void>>::value, "");
+}
+#endif

Modified: libcxx/trunk/www/cxx1z_status.html
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=222138&r1=222137&r2=222138&view=diff
==============================================================================
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Mon Nov 17 09:50:08 2014
@@ -55,10 +55,10 @@
 	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4190">N4190</a></td></td><td>LWG</td><td>Removing auto_ptr, random_shuffle(), And Old <functional> Stuff.</td><td>Urbana</td><td></td><td></td></tr>
 	<tr><td><a href="http://wiki.edg.com/twiki/pub/Wg21urbana-champaign/StrawPolls/n4284.html">N4284</a></td><td>LWG</td></td><td>Contiguous Iterators.</td><td>Urbana</td><td></td><td></td></tr>
 	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4089">N4089</a></td><td>LWG</td></td><td>Safe conversions in <code>unique_ptr<T[]></code>.</td><td>Urbana</td><td></td><td></td></tr>
-	<tr><td><a href="http://wiki.edg.com/twiki/pub/Wg21urbana-champaign/StrawPolls/N4277.html">N4277</a></td><td>LWG</td></td><td>TriviallyCopyable <code>reference_wrapper</code>.</td><td>Urbana</td><td></td><td></td></tr>
+	<tr><td><a href="http://wiki.edg.com/twiki/pub/Wg21urbana-champaign/StrawPolls/N4277.html">N4277</a></td><td>LWG</td></td><td>TriviallyCopyable <code>reference_wrapper</code>.</td><td>Urbana</td><td>Complete</td><td>3.2</td></tr>
 	<tr><td><a href="http://wiki.edg.com/twiki/pub/Wg21urbana-champaign/StrawPolls/n4258.pdf">N4258</a></td><td>LWG</td></td><td>Cleaning-up noexcept in the Library.</td><td>Urbana</td><td></td><td></td></tr>
 	<tr><td><a href="http://wiki.edg.com/twiki/pub/Wg21urbana-champaign/StrawPolls/n4279.html">N4279</a></td><td>LWG</td></td><td>Improved insertion interface for unique-key maps.</td><td>Urbana</td><td></td><td></td></tr>
-	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3911">N3911</a></td><td>LWG</td></td><td>TransformationTrait Alias <code>void_t</code>.</td><td>Urbana</td><td></td><td></td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3911">N3911</a></td><td>LWG</td></td><td>TransformationTrait Alias <code>void_t</code>.</td><td>Urbana</td><td>Complete</td><td>3.6</td></tr>
 	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4169">N4169</a></td><td>LWG</td></td><td>A proposal to add invoke function template</td><td>Urbana</td><td></td><td></td></tr>
 	<tr><td><a href="http://wiki.edg.com/twiki/pub/Wg21urbana-champaign/StrawPolls/n4280.pdf">N4280</a></td><td>LWG</td></td><td>Non-member size() and more</td><td>Urbana</td><td></td><td></td></tr>
 
@@ -83,16 +83,16 @@
  	<tr><td></td><td></td><td></td><td></td></tr>
 
 	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2106">2106</td><td><code>move_iterator</code> wrapping iterators returning prvalues</td><td>Urbana</td><td></td></tr>
-	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2129">2129</td><td>User specializations of <code>std::initializer_list</code></td><td>Urbana</td><td></td></tr>
-	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2212">2212</td><td><code>tuple_size</code> for <code>const pair</code> request <tuple> header</td><td>Urbana</td><td></td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2129">2129</td><td>User specializations of <code>std::initializer_list</code></td><td>Urbana</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2212">2212</td><td><code>tuple_size</code> for <code>const pair</code> request <tuple> header</td><td>Urbana</td><td>Complete</td></tr>
 	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2217">2217</td><td><code>operator==(sub_match, string)</code> slices on embedded '\0's</td><td>Urbana</td><td></td></tr>
-	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2233">2233</td><td><code>bad_function_call::what()</code> unhelpful</td><td>Urbana</td><td></td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2230">2230</td><td>"see below" for <code>initializer_list</code> constructors of unordered containers</td><td>Urbana</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2233">2233</td><td><code>bad_function_call::what()</code> unhelpful</td><td>Urbana</td><td>Complete</td></tr>
 	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2266">2266</td><td><code>vector</code> and <code>deque</code> have incorrect insert requirements</td><td>Urbana</td><td></td></tr>
-	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2325">2325</td><td><code>minmax_element()</code> 's behavior differing from <code>max_element()</code>'s should be noted</td><td>Urbana</td><td></td></tr>
-	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2230">2230</td><td>"see below" for <code>initializer_list</code> constructors of unordered containers</td><td>Urbana</td><td></td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2325">2325</td><td><code>minmax_element()</code>'s behavior differing from <code>max_element()</code>'s should be noted</td><td>Urbana</td><td>Complete</td></tr>
 	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2361">2361</td><td>Apply 2299 resolution throughout library</td><td>Urbana</td><td></td></tr>
-	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2365">2365</td><td>Missing noexcept in <code>shared_ptr::shared_ptr(nullptr_t)</code></td><td>Urbana</td><td></td></tr>
-	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2376">2376</td><td><code>bad_weak_ptr::what()</code> overspecified</td><td>Urbana</td><td></td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2365">2365</td><td>Missing noexcept in <code>shared_ptr::shared_ptr(nullptr_t)</code></td><td>Urbana</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2376">2376</td><td><code>bad_weak_ptr::what()</code> overspecified</td><td>Urbana</td><td>Complete</td></tr>
 	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2387">2387</td><td>More nested types that must be accessible and unambiguous</td><td>Urbana</td><td></td></tr>
 <!--
 	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#1214">1214</a></td><td>Insufficient/inconsistent key immutability requirements for associative containers</td><td>Urbana</td><td></td></tr>
@@ -100,7 +100,7 @@
 <!-- 	<tr><td></td><td></td><td></td><td></td></tr> -->
   </table>
 
-  <p>Last Updated: 10-Nov-2014</p>
+  <p>Last Updated: 17-Nov-2014</p>
 </div>
 </body>
 </html>





More information about the cfe-commits mailing list