mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-21 15:10:37 +08:00
Implement LWG 2960: nonesuch is insufficiently useless
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@359526 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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;
|
||||
}
|
@@ -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;
|
||||
}
|
Reference in New Issue
Block a user