From cac04cde5e813b3d3032aa6b48f9d5d3950f3efc Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Tue, 30 Apr 2019 00:54:38 +0000 Subject: [PATCH] Implement LWG 2960: nonesuch is insufficiently useless git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@359526 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/experimental/type_traits | 10 +++--- .../meta/meta.detect/nonesuch.fail.cpp | 32 +++++++++++++++++++ .../meta/meta.detect/nonesuch.pass.cpp | 29 +++++++++++++++++ www/cxx2a_status.html | 2 +- 4 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 test/std/experimental/utilities/meta/meta.detect/nonesuch.fail.cpp create mode 100644 test/std/experimental/utilities/meta/meta.detect/nonesuch.pass.cpp diff --git a/include/experimental/type_traits b/include/experimental/type_traits index 3127c0ea9..19466e9a5 100644 --- a/include/experimental/type_traits +++ b/include/experimental/type_traits @@ -72,6 +72,7 @@ inline namespace fundamentals_v1 { #if _LIBCPP_STD_VER > 11 +#include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -104,11 +105,10 @@ using raw_invocation_type_t = typename raw_invocation_type<_Tp>::type; // 3.3.4, Detection idiom template 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 _Op, class... _Args> diff --git a/test/std/experimental/utilities/meta/meta.detect/nonesuch.fail.cpp b/test/std/experimental/utilities/meta/meta.detect/nonesuch.fail.cpp new file mode 100644 index 000000000..e906887fe --- /dev/null +++ b/test/std/experimental/utilities/meta/meta.detect/nonesuch.fail.cpp @@ -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 +// +// +// 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 +#include + +#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; +} diff --git a/test/std/experimental/utilities/meta/meta.detect/nonesuch.pass.cpp b/test/std/experimental/utilities/meta/meta.detect/nonesuch.pass.cpp new file mode 100644 index 000000000..0d6ded52a --- /dev/null +++ b/test/std/experimental/utilities/meta/meta.detect/nonesuch.pass.cpp @@ -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 +// +// +// struct nonesuch + +#include +#include + +#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; +} diff --git a/www/cxx2a_status.html b/www/cxx2a_status.html index bf4ebdf9e..ecdb6ae91 100644 --- a/www/cxx2a_status.html +++ b/www/cxx2a_status.html @@ -278,7 +278,7 @@ 2797Trait precondition violationsSan DiegoResolved by 1285R0 2936Path comparison is defined in terms of the generic formatSan DiegoComplete 2943Problematic specification of the wide version of basic_filebuf::openSan DiegoNothing to do - 2960[fund.ts.v3] nonesuch is insufficiently uselessSan Diego + 2960[fund.ts.v3] nonesuch is insufficiently uselessSan DiegoComplete 2995basic_stringbuf default constructor forbids it from using SSO capacitySan Diego 2996Missing rvalue overloads for shared_ptr operationsSan Diego 3008make_shared (sub)object destruction semantics are not specifiedSan Diego