summaryrefslogtreecommitdiff
path: root/libcxx/test/libcxx-03/utilities/no_destroy.pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/libcxx-03/utilities/no_destroy.pass.cpp')
-rw-r--r--libcxx/test/libcxx-03/utilities/no_destroy.pass.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/libcxx/test/libcxx-03/utilities/no_destroy.pass.cpp b/libcxx/test/libcxx-03/utilities/no_destroy.pass.cpp
new file mode 100644
index 000000000000..561654d7f31f
--- /dev/null
+++ b/libcxx/test/libcxx-03/utilities/no_destroy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <__cxx03/__utility/no_destroy.h>
+#include <cassert>
+
+#include "test_macros.h"
+
+#if TEST_STD_VER > 17
+// Test constexpr-constructibility.
+constinit std::__no_destroy<int> nd_int_const(std::__uninitialized_tag{});
+#endif
+
+struct DestroyLast {
+ ~DestroyLast() { assert(*ptr == 5); }
+
+ int* ptr;
+} last;
+
+static std::__no_destroy<int> nd_int(5);
+
+int main(int, char**) {
+ last.ptr = &nd_int.__get();
+
+ return 0;
+}