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