smol_cat
joined 10 hours ago
well, you could do this in C++ if you overloaded the comparison and bitshift operators, as well as adding a macro. something like: (I am typing this on a phone, and haven't tested it
#define <<< << _ROTATOR_RIGHT_ARG <
#define _ROTATOR_RIGHT_ARG _ROTATOR_RIGHT_ARG_T()
template<typename T> class _ROTATOR_RIGHT_ARG_T {T val};
auto operator< (_ROTATOR_RIGHT_ARG_T _, auto b) -> _ROTATOR_RIGHT_ARG_T<decltype(b)>{
return _ROTATOR_RIGHT_ARG_T<decltype(b)>{.val = b};
}
then overload the bitshift operator in a similar way. the above is simply a proof of concept, should have many improvements, like adding constexpr and using concepts (the C++ feature) to ensure that the arguments are bitshiftable, but this is shit code and I would just use (as a temporary solution)
auto bitwise_rotate_l(auto a, auto b) ->/* (type shenanigans I can't be bothered to look up)*/{
return /* bitwise rotate */;
}