aboutsummaryrefslogtreecommitdiff
path: root/libcxx/test/libcxx-03/utilities/no_destroy.pass.cpp
blob: 561654d7f31fbd723d34db76bbd5fe89b3c0b0ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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;
}