From 1ac9ddf72f2c6a373cf41103a9e5fc5b294cfae4 Mon Sep 17 00:00:00 2001 From: sdottaka Date: Wed, 26 Nov 2014 22:59:38 +0900 Subject: [PATCH] boost/core/addressof.hpp: Forgot to add the file --HG-- branch : stable --- Externals/boost/boost/core/addressof.hpp | 162 +++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 Externals/boost/boost/core/addressof.hpp diff --git a/Externals/boost/boost/core/addressof.hpp b/Externals/boost/boost/core/addressof.hpp new file mode 100644 index 000000000..9ce62e183 --- /dev/null +++ b/Externals/boost/boost/core/addressof.hpp @@ -0,0 +1,162 @@ +// Copyright (C) 2002 Brad King (brad.king@kitware.com) +// Douglas Gregor (gregod@cs.rpi.edu) +// +// Copyright (C) 2002, 2008, 2013 Peter Dimov +// +// 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) + +// For more information, see http://www.boost.org + +#ifndef BOOST_CORE_ADDRESSOF_HPP +#define BOOST_CORE_ADDRESSOF_HPP + +# include +# include +# include + +namespace boost +{ + +namespace detail +{ + +template struct addr_impl_ref +{ + T & v_; + + BOOST_FORCEINLINE addr_impl_ref( T & v ): v_( v ) {} + BOOST_FORCEINLINE operator T& () const { return v_; } + +private: + addr_impl_ref & operator=(const addr_impl_ref &); +}; + +template struct addressof_impl +{ + static BOOST_FORCEINLINE T * f( T & v, long ) + { + return reinterpret_cast( + &const_cast(reinterpret_cast(v))); + } + + static BOOST_FORCEINLINE T * f( T * v, int ) + { + return v; + } +}; + +#if !defined( BOOST_NO_CXX11_NULLPTR ) + +#if !defined( BOOST_NO_CXX11_DECLTYPE ) && ( ( defined( __clang__ ) && !defined( _LIBCPP_VERSION ) ) || defined( __INTEL_COMPILER ) ) + + typedef decltype(nullptr) addr_nullptr_t; + +#else + + typedef std::nullptr_t addr_nullptr_t; + +#endif + +template<> struct addressof_impl< addr_nullptr_t > +{ + typedef addr_nullptr_t T; + + static BOOST_FORCEINLINE T * f( T & v, int ) + { + return &v; + } +}; + +template<> struct addressof_impl< addr_nullptr_t const > +{ + typedef addr_nullptr_t const T; + + static BOOST_FORCEINLINE T * f( T & v, int ) + { + return &v; + } +}; + +template<> struct addressof_impl< addr_nullptr_t volatile > +{ + typedef addr_nullptr_t volatile T; + + static BOOST_FORCEINLINE T * f( T & v, int ) + { + return &v; + } +}; + +template<> struct addressof_impl< addr_nullptr_t const volatile > +{ + typedef addr_nullptr_t const volatile T; + + static BOOST_FORCEINLINE T * f( T & v, int ) + { + return &v; + } +}; + +#endif + +} // namespace detail + +template +BOOST_FORCEINLINE +T * addressof( T & v ) +{ +#if (defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x610 ) ) ) || defined( __SUNPRO_CC ) + + return boost::detail::addressof_impl::f( v, 0 ); + +#else + + return boost::detail::addressof_impl::f( boost::detail::addr_impl_ref( v ), 0 ); + +#endif +} + +#if defined( __SUNPRO_CC ) && BOOST_WORKAROUND( __SUNPRO_CC, BOOST_TESTED_AT( 0x590 ) ) + +namespace detail +{ + +template struct addressof_addp +{ + typedef T * type; +}; + +} // namespace detail + +template< class T, std::size_t N > +BOOST_FORCEINLINE +typename detail::addressof_addp< T[N] >::type addressof( T (&t)[N] ) +{ + return &t; +} + +#endif + +// Borland doesn't like casting an array reference to a char reference +// but these overloads work around the problem. +#if defined( __BORLANDC__ ) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) +template +BOOST_FORCEINLINE +T (*addressof(T (&t)[N]))[N] +{ + return reinterpret_cast(&t); +} + +template +BOOST_FORCEINLINE +const T (*addressof(const T (&t)[N]))[N] +{ + return reinterpret_cast(&t); +} +#endif + +} // namespace boost + +#endif // BOOST_CORE_ADDRESSOF_HPP -- 2.11.0