From 0f46a60b363a2c3a7bf45149f7cacbda74b7c574 Mon Sep 17 00:00:00 2001 From: khizmax Date: Sat, 18 Jul 2015 16:31:22 +0300 Subject: [PATCH] Removed ugly reinterpret_cast --- cds/details/marked_ptr.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cds/details/marked_ptr.h b/cds/details/marked_ptr.h index 62ea44e8..01a8b1cb 100644 --- a/cds/details/marked_ptr.h +++ b/cds/details/marked_ptr.h @@ -22,7 +22,7 @@ namespace cds { template class marked_ptr { - T * m_ptr ; ///< pointer and its mark bits + T * m_ptr ; ///< pointer and its mark bits public: typedef T value_type ; ///< type of value the class points to @@ -67,14 +67,21 @@ namespace cds { private: //@cond + union pointer_cast { + T * ptr; + uintptr_t n; + + pointer_cast(T * p) : ptr(p) {} + pointer_cast(uintptr_t i) : n(i) {} + }; static uintptr_t to_int( value_type * p ) CDS_NOEXCEPT { - return reinterpret_cast( p ); + return pointer_cast(p).n; } static value_type * to_ptr( uintptr_t n ) CDS_NOEXCEPT { - return reinterpret_cast< value_type *>( n ); + return pointer_cast(n).ptr; } uintptr_t to_int() const CDS_NOEXCEPT -- 2.34.1