projects
/
libcds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
96f67ba
)
Removed ugly reinterpret_cast
author
khizmax
<libcds.dev@gmail.com>
Sat, 18 Jul 2015 13:31:22 +0000
(16:31 +0300)
committer
khizmax
<libcds.dev@gmail.com>
Sat, 18 Jul 2015 13:31:22 +0000
(16:31 +0300)
cds/details/marked_ptr.h
patch
|
blob
|
history
diff --git
a/cds/details/marked_ptr.h
b/cds/details/marked_ptr.h
index 62ea44e88d4277519cf281625e9aa8a34da9d6d4..01a8b1cbf474f45feefe4ddea0b82fbe71389051 100644
(file)
--- a/
cds/details/marked_ptr.h
+++ b/
cds/details/marked_ptr.h
@@
-22,7
+22,7
@@
namespace cds {
template <typename T, int Bitmask>
class marked_ptr
{
template <typename T, int Bitmask>
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
public:
typedef T value_type ; ///< type of value the class points to
@@
-67,14
+67,21
@@
namespace cds {
private:
//@cond
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
{
static uintptr_t to_int( value_type * p ) CDS_NOEXCEPT
{
- return
reinterpret_cast<uintptr_t>( p )
;
+ return
pointer_cast(p).n
;
}
static value_type * to_ptr( uintptr_t n ) CDS_NOEXCEPT
{
}
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
}
uintptr_t to_int() const CDS_NOEXCEPT