bitwise: add explicit accessor get
This commit is contained in:
parent
5d76fb7792
commit
5218fa8165
11
bitwise.hpp
11
bitwise.hpp
@ -153,15 +153,16 @@ namespace cruft {
|
|||||||
static_assert (SizeV > 0);
|
static_assert (SizeV > 0);
|
||||||
static_assert (OffsetV + SizeV <= sizeof (ValueT) * 8);
|
static_assert (OffsetV + SizeV <= sizeof (ValueT) * 8);
|
||||||
|
|
||||||
decltype(auto)
|
constexpr ValueT get (void) const
|
||||||
operator+ () const { return +value; }
|
|
||||||
|
|
||||||
operator auto() const
|
|
||||||
{
|
{
|
||||||
auto const MASK = (1u << SizeV) - 1u;
|
auto const MASK = ~(~0u << SizeV);
|
||||||
return (value >> OffsetV) & MASK;
|
return (value >> OffsetV) & MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
operator auto() const { return get (); }
|
||||||
|
|
||||||
|
decltype(auto) operator+ () const { return +get (); }
|
||||||
|
|
||||||
ValueT value;
|
ValueT value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user