From 2ec5bb6aecc98a73b425a9e317a44b6c494d36a8 Mon Sep 17 00:00:00 2001 From: DarkSharpness <2040703891@qq.com> Date: Fri, 12 Jul 2024 10:34:40 +0800 Subject: [PATCH] refactor(wire): use bit-field to restrict the value --- include/wire.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/wire.h b/include/wire.h index 581ddc2..7074e34 100644 --- a/include/wire.h +++ b/include/wire.h @@ -53,7 +53,7 @@ struct Wire { _Manage_t _M_func; - mutable max_size_t _M_cache; + mutable max_size_t _M_cache : _Len; mutable bool _M_holds; [[no_unique_address]] @@ -82,8 +82,7 @@ struct Wire { explicit operator max_size_t() const { if (this->_M_holds == false) { this->_M_holds = true; - constexpr auto mask = make_mask <_Len> (); - this->_M_cache = this->_M_func->call() & mask; + this->_M_cache = this->_M_func->call(); } return this->_M_cache; }