
Summary: This patch adds the second revision of <experimental/any>. I've been working from the LFTS draft found at this link. https://rawgit.com/cplusplus/fundamentals-ts/v1/fundamentals-ts.html#any Reviewers: danalbert, jroelofs, K-ballo, mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D6762 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@243728 91177308-0d34-0410-b5e6-96231b3b80d8
45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// 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'}}
|
|
} |