1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // UNSUPPORTED: c++98, c++03, c++11, c++14
10 
11 // XFAIL: dylib-has-no-bad_any_cast && !no-exceptions
12 
13 // <any>
14 
15 // any::reset() noexcept
16 
17 #include <any>
18 #include <cassert>
19 
20 #include "test_macros.h"
21 #include "any_helpers.h"
22 
23 int main(int, char**)
24 {
25     using std::any;
26     using std::any_cast;
27     // empty
28     {
29         any a;
30 
31         // noexcept check
32         static_assert(
33             noexcept(a.reset())
34           , "any.reset() must be noexcept"
35           );
36 
37         assertEmpty(a);
38 
39         a.reset();
40 
41         assertEmpty(a);
42     }
43     // small object
44     {
45         any a((small(1)));
46         assert(small::count == 1);
47         assertContains<small>(a, 1);
48 
49         a.reset();
50 
51         assertEmpty<small>(a);
52         assert(small::count == 0);
53     }
54     // large object
55     {
56         any a(large(1));
57         assert(large::count == 1);
58         assertContains<large>(a, 1);
59 
60         a.reset();
61 
62         assertEmpty<large>(a);
63         assert(large::count == 0);
64     }
65 
66   return 0;
67 }
68