# 28 Numerics library [numerics]

## 28.5 Random number generation [rand]

### 28.5.3 Requirements [rand.req]

#### 28.5.3.4 Random number engine requirements [rand.req.eng]

Table 96: Random number engine requirements [tab:rand.req.eng]
 ðŸ”— Expression Return type Pre/post-condition Complexity ðŸ”— E() Creates an engine with the same initial state as all other default-constructed engines of type E. O(size of state) ðŸ”— E(x) Creates an engine that compares equal to x. O(size of state) ðŸ”— E(s) Creates an engine with initial state determined by s. O(size of state) ðŸ”— E(q)224 Creates an engine with an initial state that depends on a sequence produced by one call to q.generate. same as complexity of q.generate called on a sequence whose length is size of state ðŸ”— e.seed() void Postconditions: e == E(). same as E() ðŸ”— e.seed(s) void Postconditions: e == E(s). same as E(s) ðŸ”— e.seed(q) void Postconditions: e == E(q). same as E(q) ðŸ”— e() T Advances e's state ei to ei+1 =TA(ei) and returns GA(ei). ðŸ”— e.discard(z)225 void Advances e's state ei to ei+z by any means equivalent to z consecutive calls e(). no worse than the complexity of z consecutive calls e() ðŸ”— x == y bool This operator is an equivalence relation. With Sx and Sy as the infinite sequences of values that would be generated by repeated future calls to x() and y(), respectively, returns true if Sx=Sy; else returns false. O(size of state) ðŸ”— x != y bool !(x == y). O(size of state) ðŸ”— os << x reference to the type of os With os.fmtflags set to ios_base​::​dec|ios_base​::​left and the fill character set to the space character, writes to os the textual representation of x's current state. In the output, adjacent numbers are separated by one or more space characters.Postconditions: The os.fmtflags and fill character are unchanged. O(size of state) ðŸ”— is >> v reference to the type of is With is.fmtflags set to ios_base​::​dec, sets v's state as determined by reading its textual representation from is. If bad input is encountered, ensures that v's state is unchanged by the operation and calls is.setstate(ios_base​::​failbit) (which may throw ios_base​::​failure ([iostate.flags])). If a textual representation written via os << x was subsequently read via is >> v, then x == v provided that there have been no intervening invocations of x or of v.Preconditions: is provides a textual representation that was previously written using an output stream whose imbued locale was the same as that of is, and whose type's template specialization arguments charT and traits were respectively the same as those of is.Postconditions: The is.fmtflags are unchanged. O(size of state)