mirror of
https://github.com/boostorg/move.git
synced 2025-07-29 20:07:13 +02:00
Add launcer helper
This commit is contained in:
53
include/boost/move/detail/launder.hpp
Normal file
53
include/boost/move/detail/launder.hpp
Normal file
@ -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
|
@ -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
|
||||
|
Reference in New Issue
Block a user