1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // UNSUPPORTED: c++98, c++03, c++11, c++14
14 // template <class ValueType>
15 // ValueType const any_cast(any const&);
17 // template <class ValueType>
18 // ValueType any_cast(any &);
20 // template <class ValueType>
21 // ValueType any_cast(any &&);
23 // Test instantiating the any_cast with a non-copyable type.
33 no_copy(no_copy &&) {}
34 no_copy(no_copy const &) = delete;
39 no_move(no_move&&) = delete;
40 no_move(no_move const&) {}
45 // expected-error@any:* {{static_assert failed "ValueType is required to be an lvalue reference or a CopyConstructible type"}}
46 // expected-error@any:* {{static_cast from 'no_copy' to 'no_copy' uses deleted function}}
47 any_cast<no_copy>(static_cast<any&>(a)); // expected-note {{requested here}}
49 // expected-error@any:* {{static_assert failed "ValueType is required to be a const lvalue reference or a CopyConstructible type"}}
50 // expected-error@any:* {{static_cast from 'const no_copy' to 'no_copy' uses deleted function}}
51 any_cast<no_copy>(static_cast<any const&>(a)); // expected-note {{requested here}}
53 any_cast<no_copy>(static_cast<any &&>(a)); // OK
55 // expected-error@any:* {{static_assert failed "ValueType is required to be an rvalue reference or a CopyConstructible type"}}
56 // expected-error@any:* {{static_cast from 'typename remove_reference<no_move &>::type' (aka 'no_move') to 'no_move' uses deleted function}}
57 any_cast<no_move>(static_cast<any &&>(a));