]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/experimental/any/any.class/any.observers/empty.pass.cpp
Vendor import of libc++ trunk r290819:
[FreeBSD/FreeBSD.git] / test / std / experimental / any / any.class / any.observers / empty.pass.cpp
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // UNSUPPORTED: c++98, c++03, c++11
11
12 // <experimental/any>
13
14 // any::empty() noexcept
15
16 #include <experimental/any>
17 #include <cassert>
18
19 #include "experimental_any_helpers.h"
20
21 int main()
22 {
23     using std::experimental::any;
24     // noexcept test
25     {
26         any a;
27         static_assert(noexcept(a.empty()), "any::empty() must be noexcept");
28     }
29     // empty
30     {
31         any a;
32         assert(a.empty());
33
34         a.clear();
35         assert(a.empty());
36
37         a = 42;
38         assert(!a.empty());
39     }
40     // small object
41     {
42         small const s(1);
43         any a(s);
44         assert(!a.empty());
45
46         a.clear();
47         assert(a.empty());
48
49         a = s;
50         assert(!a.empty());
51     }
52     // large object
53     {
54         large const l(1);
55         any a(l);
56         assert(!a.empty());
57
58         a.clear();
59         assert(a.empty());
60
61         a = l;
62         assert(!a.empty());
63     }
64 }