
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
41 lines
940 B
C++
41 lines
940 B
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>
|
|
|
|
// void swap(any &, any &) noexcept
|
|
|
|
// swap(...) just wraps any::swap(...). That function is tested elsewhere.
|
|
|
|
#include <experimental/any>
|
|
#include <cassert>
|
|
|
|
using std::experimental::any;
|
|
using std::experimental::any_cast;
|
|
|
|
int main()
|
|
{
|
|
|
|
{ // test noexcept
|
|
any a;
|
|
static_assert(noexcept(swap(a, a)), "swap(any&, any&) must be noexcept");
|
|
}
|
|
{
|
|
any a1(1);
|
|
any a2(2);
|
|
|
|
swap(a1, a2);
|
|
|
|
assert(any_cast<int>(a1) == 2);
|
|
assert(any_cast<int>(a2) == 1);
|
|
}
|
|
}
|