summaryrefslogtreecommitdiff
path: root/test/std/experimental/any/any.class/any.cons/non_copyable_value.fail.cpp
blob: 643b9621ca2fad0208caa3f68fbe11a661ac7c03 (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
//===----------------------------------------------------------------------===//
//
//                     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>

// any::any<Value>(Value &&)

// Attempt to construct any with a non-copyable type.

#include <experimental/any>

class non_copyable
{
    non_copyable(non_copyable const &);

public:
    non_copyable() {}
    non_copyable(non_copyable &&) {}
};

int main()
{
    using namespace std::experimental;
    non_copyable nc;
    any a(static_cast<non_copyable &&>(nc));
    // expected-error@experimental/any:* 1 {{static_assert failed "_ValueType must be CopyConstructible."}}
    // expected-error@experimental/any:* 1 {{calling a private constructor of class 'non_copyable'}}
}