NamedType icon indicating copy to clipboard operation
NamedType copied to clipboard

Concerning bitwise operations

Open JChMathae opened this issue 3 years ago • 1 comments

Hello,

First, thank you for this clever coding trick!

Now I have a little improvement to suggest:

  • for the BitWiseLeftShiftable/BitWiseRightShiftable skills, it would be better to use an 'int' as parameter, like: template <typename T> struct BitWiseLeftShiftable : crtp<T, fluentBitWiseLeftShiftable> { FLUENT_NODISCARD constexpr T operator<<(const int shift) const { return T(this->underlying().get() << shift); } FLUENT_CONSTEXPR17 T& operator<<=(const int shift) { this->underlying().get() <<= shift; return this->underlying(); } };

  • and also it would be fine to define an aggregate skill, alongside 'struct Arithmetic', for bitwise operations, like template<typename T> struct BitWise : BitWiseInvertable<T> , BitWiseAndable<T> , BitWiseOrable<T> , BitWiseXorable<T> , BitWiseLeftShiftable<T> , BitWiseRightShiftable<T> , Comparable<T> {};

Best regards.

JChMathae avatar Jul 08 '22 09:07 JChMathae

Another change for embedded system:

Do not only rely on the definition of STDC_HOSTED for the "use" of ... On my little ARM µC target undefining STDC_HOSTED divides ROM memory usage by ... 10 !

JChMathae avatar Jul 13 '22 14:07 JChMathae