Home | History | Annotate | Download | only in ptr.launder
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // <new>
     11 
     12 // template <class T> constexpr T* launder(T* p) noexcept;
     13 
     14 // UNSUPPORTED: c++98, c++03, c++11, c++14
     15 
     16 #include <new>
     17 #include <cassert>
     18 
     19 #include "test_macros.h"
     20 
     21 constexpr int gi = 5;
     22 constexpr float gf = 8.f;
     23 
     24 int main() {
     25 	static_assert(std::launder(&gi) == &gi, "" );
     26 	static_assert(std::launder(&gf) == &gf, "" );
     27 
     28   	const int *i = &gi;
     29   	const float *f = &gf;
     30     static_assert(std::is_same<decltype(i), decltype(std::launder(i))>::value, "");
     31     static_assert(std::is_same<decltype(f), decltype(std::launder(f))>::value, "");
     32 
     33 	assert(std::launder(i) == i);
     34 	assert(std::launder(f) == f);
     35 }
     36