blob: 1c52a64fce624bb31bd0c44f787f33030138839d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11
// <experimental/any>
// template <class ValueType>
// ValueType const any_cast(any const&);
//
// template <class ValueType>
// ValueType any_cast(any &);
//
// template <class ValueType>
// ValueType any_cast(any &&);
// Test instantiating the any_cast with a non-copyable type.
#include <experimental/any>
using std::experimental::any;
using std::experimental::any_cast;
struct no_copy
{
no_copy() {}
no_copy(no_copy &&) {}
private:
no_copy(no_copy const &);
};
int main() {
any a;
any_cast<no_copy>(static_cast<any&>(a));
any_cast<no_copy>(static_cast<any const&>(a));
any_cast<no_copy>(static_cast<any &&>(a));
// expected-error@experimental/any:* 3 {{static_assert failed "_ValueType is required to be a reference or a CopyConstructible type."}}
// expected-error@experimental/any:* 3 {{calling a private constructor of class 'no_copy'}}
}
|