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::clear() noexcept
15
16#include <experimental/any>
17#include <cassert>
18
19#include "experimental_any_helpers.h"
20
21int main()
22{
23    using std::experimental::any;
24    using std::experimental::any_cast;
25    // empty
26    {
27        any a;
28
29        // noexcept check
30        static_assert(
31            noexcept(a.clear())
32          , "any.clear() must be noexcept"
33          );
34
35        assertEmpty(a);
36
37        a.clear();
38
39        assertEmpty(a);
40    }
41    // small object
42    {
43        any a((small(1)));
44        assert(small::count == 1);
45        assertContains<small>(a, 1);
46
47        a.clear();
48
49        assertEmpty<small>(a);
50        assert(small::count == 0);
51    }
52    // large object
53    {
54        any a(large(1));
55        assert(large::count == 1);
56        assertContains<large>(a);
57
58        a.clear();
59
60        assertEmpty<large>(a);
61        assert(large::count == 0);
62    }
63}
64