aboutsummaryrefslogtreecommitdiff
path: root/test/std/utilities/any/any.nonmembers/any.cast/reference_types.fail.cpp
blob: bbc135051ef8e8a01e41c7ff125c6be436b24b2e (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
46
47
48
49
50
51
52
53
54
//===----------------------------------------------------------------------===//
//
//                     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, c++14

// <any>

// template <class ValueType>
// ValueType const* any_cast(any const *) noexcept;
//
// template <class ValueType>
// ValueType * any_cast(any *) noexcept;

#include <any>

using std::any;
using std::any_cast;

int main()
{
    any a(1);

    // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}}
    any_cast<int &>(&a); // expected-note {{requested here}}

    // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}}
    any_cast<int &&>(&a); // expected-note {{requested here}}

    // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}}
    any_cast<int const &>(&a); // expected-note {{requested here}}

    // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}}
    any_cast<int const&&>(&a); // expected-note {{requested here}}

    any const& a2 = a;

    // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}}
    any_cast<int &>(&a2); // expected-note {{requested here}}

    // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}}
    any_cast<int &&>(&a2); // expected-note {{requested here}}

    // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}}
    any_cast<int const &>(&a2); // expected-note {{requested here}}

    // expected-error@any:* 1 {{static_assert failed "_ValueType may not be a reference."}}
    any_cast<int const &&>(&a2); // expected-note {{requested here}}
}