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++03, c++11, c++14
10
11// <any>
12
13// any::reset() noexcept
14
15#include <any>
16#include <cassert>
17
18#include "test_macros.h"
19#include "any_helpers.h"
20
21int main(int, char**)
22{
23 // empty
24 {
25 std::any a;
26 ASSERT_NOEXCEPT(a.reset());
27
28 assertEmpty(a);
29
30 a.reset();
31
32 assertEmpty(a);
33 }
34 // small object
35 {
36 std::any a = small(1);
37 assert(small::count == 1);
38 assertContains<small>(a, 1);
39
40 a.reset();
41
42 assertEmpty<small>(a);
43 assert(small::count == 0);
44 }
45 // large object
46 {
47 std::any a = large(1);
48 assert(large::count == 1);
49 assertContains<large>(a, 1);
50
51 a.reset();
52
53 assertEmpty<large>(a);
54 assert(large::count == 0);
55 }
56
57 return 0;
58}
59

source code of libcxx/test/std/utilities/any/any.class/any.modifiers/reset.pass.cpp