1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14
13 // void reset() noexcept;
16 #include <type_traits>
19 #include "test_macros.h"
25 static bool dtor_called
;
27 X(const X
&) = default;
28 X
& operator=(const X
&) = default;
29 ~X() {dtor_called
= true;}
32 bool X::dtor_called
= false;
34 constexpr bool check_reset()
38 static_assert(noexcept(opt
.reset()) == true, "");
40 assert(static_cast<bool>(opt
) == false);
45 assert(static_cast<bool>(opt
) == false);
53 #if TEST_STD_VER >= 20
54 static_assert(check_reset());
58 static_assert(noexcept(opt
.reset()) == true, "");
59 assert(X::dtor_called
== false);
61 assert(X::dtor_called
== false);
62 assert(static_cast<bool>(opt
) == false);
66 X::dtor_called
= false;
68 assert(X::dtor_called
== true);
69 assert(static_cast<bool>(opt
) == false);
70 X::dtor_called
= false;