mirror of
https://github.com/sendyne/cppreg.git
synced 2025-05-09 15:14:05 +00:00
REVISED OVERFLOW IMPLEMENTATION USING INTEGRAL CONSTANT
The check_overflow implementation now relies on std::integral_constant. This avoids the definition of a constexpr bool member.
This commit is contained in:
parent
ee48bbd261
commit
8ce22c666d
@ -79,14 +79,11 @@ namespace cppreg {
|
||||
* This is only used for the template form of the write method.
|
||||
*/
|
||||
template <type value>
|
||||
struct check_overflow {
|
||||
constexpr static const bool result =
|
||||
internals::check_overflow<
|
||||
parent_register::size,
|
||||
value,
|
||||
(mask >> offset)
|
||||
>::result::value;
|
||||
};
|
||||
struct check_overflow : internals::check_overflow<
|
||||
parent_register::size,
|
||||
value,
|
||||
(mask >> offset)
|
||||
> {};
|
||||
|
||||
//!@ Field read method.
|
||||
/**
|
||||
@ -147,7 +144,7 @@ namespace cppreg {
|
||||
typename std::enable_if<
|
||||
!has_shadow
|
||||
&&
|
||||
check_overflow<value>::result,
|
||||
check_overflow<value>::value,
|
||||
T
|
||||
>::type
|
||||
write() noexcept {
|
||||
@ -168,7 +165,7 @@ namespace cppreg {
|
||||
typename std::enable_if<
|
||||
has_shadow
|
||||
&&
|
||||
check_overflow<value>::result,
|
||||
check_overflow<value>::value,
|
||||
T
|
||||
>::type
|
||||
write() noexcept {
|
||||
|
@ -131,7 +131,7 @@ namespace cppreg {
|
||||
typename std::enable_if<
|
||||
(internals::check_overflow<
|
||||
Register::size, new_value, (F::mask >> F::offset)
|
||||
>::result::value),
|
||||
>::value),
|
||||
T
|
||||
>::type&&
|
||||
with() const && noexcept {
|
||||
|
@ -34,10 +34,7 @@ namespace internals {
|
||||
typename RegisterType<W>::type value,
|
||||
typename RegisterType<W>::type limit
|
||||
>
|
||||
struct check_overflow {
|
||||
using result =
|
||||
typename std::integral_constant<bool, value <= limit>::type;
|
||||
};
|
||||
struct check_overflow : std::integral_constant<bool, value <= limit> {};
|
||||
|
||||
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ namespace cppreg {
|
||||
typename std::enable_if<
|
||||
internals::check_overflow<
|
||||
size, value, (F::mask >> F::offset)
|
||||
>::result::value,
|
||||
>::value,
|
||||
T
|
||||
>::type&&
|
||||
merge_write() noexcept {
|
||||
|
Loading…
x
Reference in New Issue
Block a user