1#ifndef BOOST_CORE_LAUNDER_HPP_INCLUDED
2#define BOOST_CORE_LAUNDER_HPP_INCLUDED
3
4// MS compatible compilers support #pragma once
5
6#if defined(_MSC_VER) && (_MSC_VER >= 1020)
7# pragma once
8#endif
9
10// Copyright 2023 Peter Dimov
11// Distributed under the Boost Software License, Version 1.0.
12// https://www.boost.org/LICENSE_1_0.txt
13
14#include <boost/config.hpp>
15
16#if defined(__has_builtin)
17# if __has_builtin(__builtin_launder)
18# define BOOST_CORE_HAS_BUILTIN_LAUNDER
19# endif
20#endif
21
22#if defined(BOOST_MSVC) && BOOST_MSVC < 1920
23
24// msvc-14.1 suffers from internal compiler errors when using std::launder
25// https://github.com/boostorg/core/issues/160
26// https://github.com/boostorg/optional/issues/122
27
28#elif (BOOST_CXX_VERSION >= 201703L) && !defined(BOOST_CORE_HAS_BUILTIN_LAUNDER)
29
30#include <new>
31
32#if defined(__cpp_lib_launder)
33# define BOOST_CORE_HAS_STD_LAUNDER
34#endif
35
36#endif
37
38namespace boost
39{
40namespace core
41{
42
43#if defined(BOOST_CORE_HAS_BUILTIN_LAUNDER)
44
45template<class T> T* launder( T* p )
46{
47 return __builtin_launder( p );
48}
49
50#elif defined(BOOST_CORE_HAS_STD_LAUNDER)
51
52template<class T> T* launder( T* p )
53{
54 return std::launder( p );
55}
56
57#else
58
59template<class T> T* launder( T* p )
60{
61 return p;
62}
63
64#endif
65
66} // namespace core
67} // namespace boost
68
69#endif // #ifndef BOOST_CORE_LAUNDER_HPP_INCLUDED
70

source code of boost/libs/core/include/boost/core/launder.hpp