mirror of
https://github.com/boostorg/utility.git
synced 2025-05-09 23:14:02 +00:00
parent
bafe37fdab
commit
a5b85eda07
@ -1,6 +1,7 @@
|
|||||||
// Copyright (C) 2002 Brad King (brad.king@kitware.com)
|
// Copyright (C) 2002 Brad King (brad.king@kitware.com)
|
||||||
// Douglas Gregor (gregod@cs.rpi.edu)
|
// Douglas Gregor (gregod@cs.rpi.edu)
|
||||||
// Peter Dimov
|
//
|
||||||
|
// Copyright (C) 2002, 2008 Peter Dimov
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
// Distributed under the Boost Software License, Version 1.0. (See
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -14,29 +15,33 @@
|
|||||||
# include <boost/config.hpp>
|
# include <boost/config.hpp>
|
||||||
# include <boost/detail/workaround.hpp>
|
# include <boost/detail/workaround.hpp>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost
|
||||||
|
|
||||||
// Do not make addressof() inline. Breaks MSVC 7. (Peter Dimov)
|
|
||||||
|
|
||||||
// VC7 strips const from nested classes unless we add indirection here
|
|
||||||
# if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
|
|
||||||
|
|
||||||
template<class T> struct _addp
|
|
||||||
{
|
{
|
||||||
typedef T * type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T> typename _addp<T>::type
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
# else
|
template<class T> struct addressof_impl
|
||||||
template <typename T> T*
|
{
|
||||||
# endif
|
static inline T * f( T & v, long )
|
||||||
addressof(T& v)
|
|
||||||
{
|
{
|
||||||
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 )
|
||||||
|
{
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
template<class T> T * addressof( T & v )
|
||||||
|
{
|
||||||
|
return boost::detail::addressof_impl<T>::f( v, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
// Borland doesn't like casting an array reference to a char reference
|
// Borland doesn't like casting an array reference to a char reference
|
||||||
// but these overloads work around the problem.
|
// but these overloads work around the problem.
|
||||||
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||||
@ -53,6 +58,6 @@ const T (*addressof(const T (&t)[N]))[N]
|
|||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
}
|
} // namespace boost
|
||||||
|
|
||||||
#endif // BOOST_UTILITY_ADDRESSOF_HPP
|
#endif // BOOST_UTILITY_ADDRESSOF_HPP
|
||||||
|
Loading…
x
Reference in New Issue
Block a user