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> {};
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 !
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.