[libcxx-commits] [libcxx] r359526 - Implement LWG 2960: nonesuch is insufficiently useless

Marshall Clow via libcxx-commits libcxx-commits at lists.llvm.org
Mon Apr 29 17:54:38 PDT 2019


Author: marshall
Date: Mon Apr 29 17:54:38 2019
New Revision: 359526

URL: http://llvm.org/viewvc/llvm-project?rev=359526&view=rev
Log:
Implement LWG 2960: nonesuch is insufficiently useless

Added:
    libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/nonesuch.fail.cpp
    libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/nonesuch.pass.cpp
Modified:
    libcxx/trunk/include/experimental/type_traits
    libcxx/trunk/www/cxx2a_status.html

Modified: libcxx/trunk/include/experimental/type_traits
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/type_traits?rev=359526&r1=359525&r2=359526&view=diff
==============================================================================
--- libcxx/trunk/include/experimental/type_traits (original)
+++ libcxx/trunk/include/experimental/type_traits Mon Apr 29 17:54:38 2019
@@ -72,6 +72,7 @@ inline namespace fundamentals_v1 {
 
 #if _LIBCPP_STD_VER > 11
 
+#include <initializer_list>
 #include <type_traits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -104,11 +105,10 @@ using raw_invocation_type_t = typename r
 // 3.3.4, Detection idiom
 template <class...> using void_t = void;
 
-struct nonesuch {
-    nonesuch()  = delete;
-    ~nonesuch() = delete;
-    nonesuch      (nonesuch const&) = delete;
-    void operator=(nonesuch const&) = delete;
+struct nonesuch : private _VSTD::__nat { // make nonesuch "not an aggregate"
+  ~nonesuch() = delete;
+  nonesuch      (nonesuch const&) = delete;
+  void operator=(nonesuch const&) = delete;
   };
 
 template <class _Default, class _AlwaysVoid, template <class...> class _Op, class... _Args>

Added: libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/nonesuch.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/nonesuch.fail.cpp?rev=359526&view=auto
==============================================================================
--- libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/nonesuch.fail.cpp (added)
+++ libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/nonesuch.fail.cpp Mon Apr 29 17:54:38 2019
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+// <experimental/type_traits>
+//
+//  struct nonesuch;
+//	  nonesuch has no default constructor (C++17 §15.1) 
+//    or initializer-list constructor (C++17 §11.6.4), 
+//    and is not an aggregate (C++17 §11.6.1).
+
+
+#include <experimental/type_traits>
+#include <string>
+
+#include "test_macros.h"
+
+namespace ex = std::experimental;
+
+void doSomething (const ex::nonesuch &) {}
+
+int main(int, char**) {
+    ex::nonesuch *e0 = new ex::nonesuch; // expected-error {{no matching constructor for initialization of 'ex::nonesuch'}}
+    doSomething({}); // expected-error{{no matching function for call to 'doSomething'}}
+
+    return 0;
+}

Added: libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/nonesuch.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/nonesuch.pass.cpp?rev=359526&view=auto
==============================================================================
--- libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/nonesuch.pass.cpp (added)
+++ libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/nonesuch.pass.cpp Mon Apr 29 17:54:38 2019
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+// <experimental/type_traits>
+//
+//  struct nonesuch
+
+#include <experimental/type_traits>
+#include <string>
+
+#include "test_macros.h"
+
+namespace ex = std::experimental;
+
+struct such {};
+void foo(const such &) {}
+void foo(const ex::nonesuch &) {}
+
+int main(int, char**) {
+    foo({});  // nonesuch is not an aggregate
+
+    return 0;
+}

Modified: libcxx/trunk/www/cxx2a_status.html
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx2a_status.html?rev=359526&r1=359525&r2=359526&view=diff
==============================================================================
--- libcxx/trunk/www/cxx2a_status.html (original)
+++ libcxx/trunk/www/cxx2a_status.html Mon Apr 29 17:54:38 2019
@@ -278,7 +278,7 @@
 	<tr><td><a href="https://wg21.link/LWG2797">2797</a></td><td>Trait precondition violations</td><td>San Diego</td><td>Resolved by 1285R0</td></tr>
 	<tr><td><a href="https://wg21.link/LWG2936">2936</a></td><td>Path comparison is defined in terms of the generic format</td><td>San Diego</td><td>Complete</td></tr>
 	<tr><td><a href="https://wg21.link/LWG2943">2943</a></td><td>Problematic specification of the wide version of <tt>basic_filebuf::open</tt></td><td>San Diego</td><td>Nothing to do</td></tr>
-	<tr><td><a href="https://wg21.link/LWG2960">2960</a></td><td>[fund.ts.v3] <tt>nonesuch</tt> is insufficiently useless</td><td>San Diego</td><td></td></tr>
+	<tr><td><a href="https://wg21.link/LWG2960">2960</a></td><td>[fund.ts.v3] <tt>nonesuch</tt> is insufficiently useless</td><td>San Diego</td><td>Complete</td></tr>
 	<tr><td><a href="https://wg21.link/LWG2995">2995</a></td><td><tt>basic_stringbuf</tt> default constructor forbids it from using SSO capacity</td><td>San Diego</td><td></td></tr>
 	<tr><td><a href="https://wg21.link/LWG2996">2996</a></td><td>Missing rvalue overloads for <tt>shared_ptr</tt> operations</td><td>San Diego</td><td></td></tr>
 	<tr><td><a href="https://wg21.link/LWG3008">3008</a></td><td><tt>make_shared</tt> (sub)object destruction semantics are not specified</td><td>San Diego</td><td></td></tr>




More information about the libcxx-commits mailing list