mirror of
https://github.com/boostorg/utility.git
synced 2025-05-09 15:04:00 +00:00
addressof.hpp:
- Peter Dimov suggested a fix to deal with those evil cv-qualifiers [SVN r13431]
This commit is contained in:
parent
029ff9828f
commit
00560e8e17
@ -17,36 +17,11 @@
|
|||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
struct addressof_helper {};
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline T* addressof(T& v)
|
inline T* addressof(T& v)
|
||||||
{
|
{
|
||||||
return reinterpret_cast<T*>(
|
return reinterpret_cast<T*>(
|
||||||
&reinterpret_cast<detail::addressof_helper&>(v));
|
&const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline const T* addressof(const T& v)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<const T*>(
|
|
||||||
&reinterpret_cast<const detail::addressof_helper&>(v));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline volatile T* addressof(volatile T& v)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<volatile T*>(
|
|
||||||
&reinterpret_cast<volatile detail::addressof_helper&>(v));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline const volatile T* addressof(const volatile T& v)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<const volatile T*>(
|
|
||||||
&reinterpret_cast<const volatile detail::addressof_helper&>(v));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user