refactor(wire): use bit-field to restrict the value
This commit is contained in:
@ -53,7 +53,7 @@ struct Wire {
|
|||||||
|
|
||||||
_Manage_t _M_func;
|
_Manage_t _M_func;
|
||||||
|
|
||||||
mutable max_size_t _M_cache;
|
mutable max_size_t _M_cache : _Len;
|
||||||
mutable bool _M_holds;
|
mutable bool _M_holds;
|
||||||
|
|
||||||
[[no_unique_address]]
|
[[no_unique_address]]
|
||||||
@ -82,8 +82,7 @@ struct Wire {
|
|||||||
explicit operator max_size_t() const {
|
explicit operator max_size_t() const {
|
||||||
if (this->_M_holds == false) {
|
if (this->_M_holds == false) {
|
||||||
this->_M_holds = true;
|
this->_M_holds = true;
|
||||||
constexpr auto mask = make_mask <_Len> ();
|
this->_M_cache = this->_M_func->call();
|
||||||
this->_M_cache = this->_M_func->call() & mask;
|
|
||||||
}
|
}
|
||||||
return this->_M_cache;
|
return this->_M_cache;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user