mirror of
https://github.com/sendyne/cppreg.git
synced 2025-05-11 05:33:52 +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.
|
* This is only used for the template form of the write method.
|
||||||
*/
|
*/
|
||||||
template <type value>
|
template <type value>
|
||||||
struct check_overflow {
|
struct check_overflow : internals::check_overflow<
|
||||||
constexpr static const bool result =
|
parent_register::size,
|
||||||
internals::check_overflow<
|
value,
|
||||||
parent_register::size,
|
(mask >> offset)
|
||||||
value,
|
> {};
|
||||||
(mask >> offset)
|
|
||||||
>::result::value;
|
|
||||||
};
|
|
||||||
|
|
||||||
//!@ Field read method.
|
//!@ Field read method.
|
||||||
/**
|
/**
|
||||||
@ -147,7 +144,7 @@ namespace cppreg {
|
|||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
!has_shadow
|
!has_shadow
|
||||||
&&
|
&&
|
||||||
check_overflow<value>::result,
|
check_overflow<value>::value,
|
||||||
T
|
T
|
||||||
>::type
|
>::type
|
||||||
write() noexcept {
|
write() noexcept {
|
||||||
@ -168,7 +165,7 @@ namespace cppreg {
|
|||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
has_shadow
|
has_shadow
|
||||||
&&
|
&&
|
||||||
check_overflow<value>::result,
|
check_overflow<value>::value,
|
||||||
T
|
T
|
||||||
>::type
|
>::type
|
||||||
write() noexcept {
|
write() noexcept {
|
||||||
|
@ -131,7 +131,7 @@ namespace cppreg {
|
|||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
(internals::check_overflow<
|
(internals::check_overflow<
|
||||||
Register::size, new_value, (F::mask >> F::offset)
|
Register::size, new_value, (F::mask >> F::offset)
|
||||||
>::result::value),
|
>::value),
|
||||||
T
|
T
|
||||||
>::type&&
|
>::type&&
|
||||||
with() const && noexcept {
|
with() const && noexcept {
|
||||||
|
@ -34,10 +34,7 @@ namespace internals {
|
|||||||
typename RegisterType<W>::type value,
|
typename RegisterType<W>::type value,
|
||||||
typename RegisterType<W>::type limit
|
typename RegisterType<W>::type limit
|
||||||
>
|
>
|
||||||
struct check_overflow {
|
struct check_overflow : std::integral_constant<bool, value <= limit> {};
|
||||||
using result =
|
|
||||||
typename std::integral_constant<bool, value <= limit>::type;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ namespace cppreg {
|
|||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
internals::check_overflow<
|
internals::check_overflow<
|
||||||
size, value, (F::mask >> F::offset)
|
size, value, (F::mask >> F::offset)
|
||||||
>::result::value,
|
>::value,
|
||||||
T
|
T
|
||||||
>::type&&
|
>::type&&
|
||||||
merge_write() noexcept {
|
merge_write() noexcept {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user