2 * Distributed under the Boost Software License, Version 1.0.
3 * (See accompanying file LICENSE_1_0.txt or copy at
4 * http://www.boost.org/LICENSE_1_0.txt)
6 * Copyright (c) 2009 Helge Bahmann
7 * Copyright (c) 2012 Tim Blechmann
8 * Copyright (c) 2013 - 2014 Andrey Semashev
11 * \file atomic/detail/bitwise_cast.hpp
13 * This header defines \c bitwise_cast used to convert between storage and value types
16 #ifndef BOOST_ATOMIC_DETAIL_BITWISE_CAST_HPP_INCLUDED_
17 #define BOOST_ATOMIC_DETAIL_BITWISE_CAST_HPP_INCLUDED_
19 #include <boost/atomic/detail/config.hpp>
20 #if !defined(BOOST_ATOMIC_DETAIL_HAS_BUILTIN_MEMCPY)
24 #ifdef BOOST_HAS_PRAGMA_ONCE
32 template< typename To, typename From >
33 BOOST_FORCEINLINE To bitwise_cast(From const& from) BOOST_NOEXCEPT
40 BOOST_ATOMIC_DETAIL_MEMCPY
42 &reinterpret_cast< char& >(value.to),
43 &reinterpret_cast< const char& >(from),
44 (sizeof(From) < sizeof(To) ? sizeof(From) : sizeof(To))
50 } // namespace atomics
53 #endif // BOOST_ATOMIC_DETAIL_BITWISE_CAST_HPP_INCLUDED_