This removes the __detail::_Shift class template, replacing it with a constexpr function template __pow2m1. Instead of using the _Mod class template to calculate a modulus just perform a bitwise AND with the result of __pow2m1. This works because the places that change all perform a modulus operation with a power of two, x mod 2^w, which can be replaced with x & (2^w - 1). The _Mod class template is still needed by linear_congruential_engine which needs to calculate (a * x + c) % m without overflow. I'm not committing this yet, please review and check I've not broken anything.