brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1011 B · 404cdbc Raw
36 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// <new>10 11// template <class T> constexpr T* launder(T* p) noexcept;12 13// UNSUPPORTED: c++03, c++11, c++1414 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(&gi) == &gi, "" );24    static_assert(std::launder(&gf) == &gf, "" );25 26    const int *i = &gi;27    const float *f = &gf;28    static_assert(std::is_same<decltype(i), decltype(std::launder(i))>::value, "");29    static_assert(std::is_same<decltype(f), decltype(std::launder(f))>::value, "");30 31    assert(std::launder(i) == i);32    assert(std::launder(f) == f);33 34  return 0;35}36