Fix #9170 - Add BOOST_FORCEINLINE in address_of for performance issues

[SVN r86125]
This commit is contained in:
Joel Falcou 2013-10-01 15:05:39 +00:00
parent b39e4e5aea
commit a90bc68a7f

View File

@ -25,8 +25,8 @@ template<class T> struct addr_impl_ref
{
T & v_;
inline addr_impl_ref( T & v ): v_( v ) {}
inline operator T& () const { return 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 &);
@ -34,13 +34,13 @@ private:
template<class T> struct addressof_impl
{
static inline T * f( T & v, long )
static BOOST_FORCEINLINE T * f( T & v, long )
{
return reinterpret_cast<T*>(
&const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
}
static inline T * f( T * v, int )
static BOOST_FORCEINLINE T * f( T * v, int )
{
return v;
}
@ -48,7 +48,9 @@ template<class T> struct addressof_impl
} // namespace detail
template<class T> T * addressof( T & v )
template<class T>
BOOST_FORCEINLINE
T * addressof( T & v )
{
#if (defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x610 ) ) ) || defined( __SUNPRO_CC )
@ -74,6 +76,7 @@ template<class T> struct addressof_addp
} // namespace detail
template< class T, std::size_t N >
BOOST_FORCEINLINE
typename detail::addressof_addp< T[N] >::type addressof( T (&t)[N] )
{
return &t;
@ -85,12 +88,14 @@ typename detail::addressof_addp< T[N] >::type addressof( T (&t)[N] )
// but these overloads work around the problem.
#if defined( __BORLANDC__ ) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
template<typename T,std::size_t N>
BOOST_FORCEINLINE
T (*addressof(T (&t)[N]))[N]
{
return reinterpret_cast<T(*)[N]>(&t);
}
template<typename T,std::size_t N>
BOOST_FORCEINLINE
const T (*addressof(const T (&t)[N]))[N]
{
return reinterpret_cast<const T(*)[N]>(&t);