Skip to content

Commit

Permalink
Add launcer helper
Browse files Browse the repository at this point in the history
  • Loading branch information
igaztanaga committed Apr 15, 2024
1 parent 08f16be commit d6b9702
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
53 changes: 53 additions & 0 deletions include/boost/move/detail/launder.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2014-2015. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/container for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_MOVE_DETAIL_LAUNDER_HPP
#define BOOST_MOVE_DETAIL_LAUNDER_HPP

#ifndef BOOST_CONFIG_HPP
# include <boost/config.hpp>
#endif

#if defined(BOOST_HAS_PRAGMA_ONCE)
# pragma once
#endif

#include <boost/move/detail/workaround.hpp>

namespace boost {
namespace move_detail {

#if defined(BOOST_MOVE_HAS_BUILTIN_LAUNDER)

template<class T>
BOOST_MOVE_FORCEINLINE T* launder(T* p)
{
return __builtin_launder( p );
}

#else

template<class T>
BOOST_MOVE_FORCEINLINE T* launder(T* p)
{
return p;
}

#endif

template<class T>
BOOST_MOVE_FORCEINLINE T launder_cast(const volatile void* p)
{
return (launder)((T)p);
}

} //namespace move_detail {
} //namespace boost {

#endif //#ifndef BOOST_MOVE_DETAIL_LAUNDER_HPP
7 changes: 6 additions & 1 deletion include/boost/move/detail/workaround.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,10 @@ template<unsigned> struct static_assert_test {};
#define BOOST_MOVE_INTRINSIC_CAST BOOST_MOVE_FORCEINLINE
#endif

#endif //#ifndef BOOST_MOVE_DETAIL_WORKAROUND_HPP
#if defined(__has_builtin)
#if __has_builtin(__builtin_launder)
#define BOOST_MOVE_HAS_BUILTIN_LAUNDER
#endif
#endif

#endif //#ifndef BOOST_MOVE_DETAIL_WORKAROUND_HPP

0 comments on commit d6b9702

Please sign in to comment.