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// <new>
10
11// template <class T> constexpr T* launder(T* p) noexcept;
12
13// UNSUPPORTED: c++03, c++11, c++14
14
15#include <cassert>
16#include <new>
17#include <type_traits>
18
19constexpr int gi = 5;
20constexpr float gf = 8.f;
21
22int main(int, char**) {
23 static_assert(std::launder(p: &gi) == &gi, "" );
24 static_assert(std::launder(p: &gf) == &gf, "" );
25
26 const int *i = &gi;
27 const float *f = &gf;
28 static_assert(std::is_same<decltype(i), decltype(std::launder(p: i))>::value, "");
29 static_assert(std::is_same<decltype(f), decltype(std::launder(p: f))>::value, "");
30
31 assert(std::launder(i) == i);
32 assert(std::launder(f) == f);
33
34 return 0;
35}
36

source code of libcxx/test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp