Boost logo

Boost-Commit :

From: pdimov_at_[hidden]
Date: 2008-04-21 17:42:30


Author: pdimov
Date: 2008-04-21 17:42:29 EDT (Mon, 21 Apr 2008)
New Revision: 44705
URL: http://svn.boost.org/trac/boost/changeset/44705

Log:
Fix #1846.
Text files modified:
   trunk/boost/utility/addressof.hpp | 39 ++++++++++++++++++++++-----------------
   1 files changed, 22 insertions(+), 17 deletions(-)

Modified: trunk/boost/utility/addressof.hpp
==============================================================================
--- trunk/boost/utility/addressof.hpp (original)
+++ trunk/boost/utility/addressof.hpp 2008-04-21 17:42:29 EDT (Mon, 21 Apr 2008)
@@ -1,6 +1,7 @@
 // Copyright (C) 2002 Brad King (brad.king_at_[hidden])
 // Douglas Gregor (gregod_at_[hidden])
-// Peter Dimov
+//
+// Copyright (C) 2002, 2008 Peter Dimov
 //
 // Distributed under the Boost Software License, Version 1.0. (See
 // accompanying file LICENSE_1_0.txt or copy at
@@ -14,27 +15,31 @@
 # include <boost/config.hpp>
 # include <boost/detail/workaround.hpp>
 
-namespace boost {
-
-// Do not make addressof() inline. Breaks MSVC 7. (Peter Dimov)
+namespace boost
+{
 
-// VC7 strips const from nested classes unless we add indirection here
-# if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
+namespace detail
+{
 
-template<class T> struct _addp
+template<class T> struct addressof_impl
 {
- typedef T * type;
+ static inline 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 )
+ {
+ return v;
+ }
 };
-
-template <typename T> typename _addp<T>::type
 
-# else
-template <typename T> T*
-# endif
-addressof(T& v)
+} // namespace detail
+
+template<class T> T * addressof( T & v )
 {
- return reinterpret_cast<T*>(
- &const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
+ return boost::detail::addressof_impl<T>::f( v, 0 );
 }
 
 // Borland doesn't like casting an array reference to a char reference
@@ -53,6 +58,6 @@
 }
 # endif
 
-}
+} // namespace boost
 
 #endif // BOOST_UTILITY_ADDRESSOF_HPP


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk