The transition algorithm
employs a twisted generalized feedback shift register
defined by shift values 
n and 
m, a twist value 
r,
and a conditional xor-mask 
a.To improve the uniformity of the result,
the bits of the raw shift register are additionally 
tempered
(i.e., scrambled) according to a bit-scrambling matrix
defined by values 
u, 
d, 
s, 
b, 
t, 
c, and 
ℓ.The state transition is performed as follows:
- a)
 Concatenate
     the upper  w−r bits of  Xi−n
   with
     the lower  r bits of  Xi+1−n
   to obtain an unsigned integer value  Y.
- b)With  α=a⋅(Ybitand1),
   set  Xi to
      Xi+m−nxor(Yrshift1)xorα.
The sequence 
X is initialized
with the help of an initialization multiplier 
f.The generation algorithm
 determines the unsigned integer values 
z1,z2,z3,z4 as follows,
 then delivers 
z4 as its result:
- a)
 Let  z1=Xixor((Xirshiftu)bitandd).
- b)Let  z2=z1xor((z1lshiftws)bitandb).
- c)Let  z3=z2xor((z2lshiftwt)bitandc).
- d)
template<class UIntType, size_t w, size_t n, size_t m, size_t r,
         UIntType a, size_t u, UIntType d, size_t s,
         UIntType b, size_t t,
         UIntType c, size_t l, UIntType f>
  class mersenne_twister_engine {
  public:
        using result_type = UIntType;
        static constexpr size_t word_size = w;
    static constexpr size_t state_size = n;
    static constexpr size_t shift_size = m;
    static constexpr size_t mask_bits = r;
    static constexpr UIntType xor_mask = a;
    static constexpr size_t tempering_u = u;
    static constexpr UIntType tempering_d = d;
    static constexpr size_t tempering_s = s;
    static constexpr UIntType tempering_b = b;
    static constexpr size_t tempering_t = t;
    static constexpr UIntType tempering_c = c;
    static constexpr size_t tempering_l = l;
    static constexpr UIntType initialization_multiplier = f;
    static constexpr result_type min() { return 0; }
    static constexpr result_type max() { return  2w−1; }
    static constexpr result_type default_seed = 5489u;
        mersenne_twister_engine() : mersenne_twister_engine(default_seed) {}
    explicit mersenne_twister_engine(result_type value);
    template<class Sseq> explicit mersenne_twister_engine(Sseq& q);
    void seed(result_type value = default_seed);
    template<class Sseq> void seed(Sseq& q);
        result_type operator()();
    void discard(unsigned long long z);
  };