28#ifndef SC_PTR_FLAG_H_INCLUDED_
29#define SC_PTR_FLAG_H_INCLUDED_
40 typedef std::uintptr_t uintptr_type;
41 static_assert(
alignof(T) > 1
42 ,
"Unsupported platform/type, need spare LSB of pointer to store flag" );
51 : m_data(reinterpret_cast<uintptr_type>(p))
57 {
reset(p);
return *
this; }
64 {
return reinterpret_cast<pointer>( m_data & pointer_mask ); }
68 m_data =
reinterpret_cast<uintptr_type
>(p) |
static_cast<uintptr_type
>(
get_flag());
72 {
return ( m_data & flag_mask ) != 0x0; }
75 { m_data = ( m_data & pointer_mask ) |
static_cast<uintptr_type
>(f); }
78 static const uintptr_type flag_mask = 0x1;
79 static const uintptr_type pointer_mask = ~flag_mask;
pointer operator->() const
sc_ptr_flag & operator=(pointer p)
sc_ptr_flag(pointer p, bool f=false)
reference operator*() const