Changeset 44705


Ignore:
Timestamp:
Apr 21, 2008, 9:42:29 PM (10 years ago)
Author:
Peter Dimov
Message:

Fix #1846.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/boost/utility/addressof.hpp

    r27712 r44705  
    11// Copyright (C) 2002 Brad King (brad.king@kitware.com)
    22//                    Douglas Gregor (gregod@cs.rpi.edu)
    3 //                    Peter Dimov
     3//
     4// Copyright (C) 2002, 2008 Peter Dimov
    45//
    56// Distributed under the Boost Software License, Version 1.0. (See
     
    1516# include <boost/detail/workaround.hpp>
    1617
    17 namespace boost {
     18namespace boost
     19{
    1820
    19 // Do not make addressof() inline. Breaks MSVC 7. (Peter Dimov)
     21namespace detail
     22{
    2023
    21 // VC7 strips const from nested classes unless we add indirection here
    22 # if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
     24template<class T> struct addressof_impl
     25{
     26    static inline T * f( T & v, long )
     27    {
     28        return reinterpret_cast<T*>(
     29            &const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
     30    }
    2331
    24 template<class T> struct _addp
     32    static inline T * f( T * v, int )
     33    {
     34        return v;
     35    }
     36};
     37
     38} // namespace detail
     39
     40template<class T> T * addressof( T & v )
    2541{
    26     typedef T * type;
    27 };
    28    
    29 template <typename T> typename _addp<T>::type
    30 
    31 # else
    32 template <typename T> T*
    33 # endif
    34 addressof(T& v)
    35 {
    36   return reinterpret_cast<T*>(
    37        &const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
     42    return boost::detail::addressof_impl<T>::f( v, 0 );
    3843}
    3944
     
    5459# endif
    5560
    56 }
     61} // namespace boost
    5762
    5863#endif // BOOST_UTILITY_ADDRESSOF_HPP
Note: See TracChangeset for help on using the changeset viewer.