mirror of
https://github.com/boostorg/utility.git
synced 2025-05-09 15:04:00 +00:00
Fix #9170 - Add BOOST_FORCEINLINE in address_of for performance issues
[SVN r86125]
This commit is contained in:
parent
b39e4e5aea
commit
a90bc68a7f
@ -25,8 +25,8 @@ template<class T> struct addr_impl_ref
|
|||||||
{
|
{
|
||||||
T & v_;
|
T & v_;
|
||||||
|
|
||||||
inline addr_impl_ref( T & v ): v_( v ) {}
|
BOOST_FORCEINLINE addr_impl_ref( T & v ): v_( v ) {}
|
||||||
inline operator T& () const { return v_; }
|
BOOST_FORCEINLINE operator T& () const { return v_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
addr_impl_ref & operator=(const addr_impl_ref &);
|
addr_impl_ref & operator=(const addr_impl_ref &);
|
||||||
@ -34,13 +34,13 @@ private:
|
|||||||
|
|
||||||
template<class T> struct addressof_impl
|
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*>(
|
return reinterpret_cast<T*>(
|
||||||
&const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
|
&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;
|
return v;
|
||||||
}
|
}
|
||||||
@ -48,7 +48,9 @@ template<class T> struct addressof_impl
|
|||||||
|
|
||||||
} // namespace detail
|
} // 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 )
|
#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
|
} // namespace detail
|
||||||
|
|
||||||
template< class T, std::size_t N >
|
template< class T, std::size_t N >
|
||||||
|
BOOST_FORCEINLINE
|
||||||
typename detail::addressof_addp< T[N] >::type addressof( T (&t)[N] )
|
typename detail::addressof_addp< T[N] >::type addressof( T (&t)[N] )
|
||||||
{
|
{
|
||||||
return &t;
|
return &t;
|
||||||
@ -85,12 +88,14 @@ typename detail::addressof_addp< T[N] >::type addressof( T (&t)[N] )
|
|||||||
// but these overloads work around the problem.
|
// but these overloads work around the problem.
|
||||||
#if defined( __BORLANDC__ ) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
#if defined( __BORLANDC__ ) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||||
template<typename T,std::size_t N>
|
template<typename T,std::size_t N>
|
||||||
|
BOOST_FORCEINLINE
|
||||||
T (*addressof(T (&t)[N]))[N]
|
T (*addressof(T (&t)[N]))[N]
|
||||||
{
|
{
|
||||||
return reinterpret_cast<T(*)[N]>(&t);
|
return reinterpret_cast<T(*)[N]>(&t);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T,std::size_t N>
|
template<typename T,std::size_t N>
|
||||||
|
BOOST_FORCEINLINE
|
||||||
const T (*addressof(const T (&t)[N]))[N]
|
const T (*addressof(const T (&t)[N]))[N]
|
||||||
{
|
{
|
||||||
return reinterpret_cast<const T(*)[N]>(&t);
|
return reinterpret_cast<const T(*)[N]>(&t);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user