Attempt to fix addressof in trunk to handle classes with conversion operators. Refs #2878.

[SVN r51872]
This commit is contained in:
Peter Dimov
2014-06-01 01:15:42 +03:00
parent e45f2cd9d3
commit 2f4e34a658
3 changed files with 187 additions and 0 deletions
+16
View File
@@ -21,6 +21,14 @@ namespace boost
namespace detail
{
template<class T> struct addr_impl_ref
{
T & v_;
inline addr_impl_ref( T & v ): v_( v ) {}
inline operator T& () const { return v_; }
};
template<class T> struct addressof_impl
{
static inline T * f( T & v, long )
@@ -39,7 +47,15 @@ template<class T> struct addressof_impl
template<class T> T * addressof( T & v )
{
#if BOOST_WORKAROUND( __BORLANDC__, < 0x560 )
return boost::detail::addressof_impl<T>::f( v, 0 );
#else
return boost::detail::addressof_impl<T>::f( boost::detail::addr_impl_ref<T>( v ), 0 );
#endif
}
// Borland doesn't like casting an array reference to a char reference