- Title
- UniformRandomBitGenerator should validate min and max
- Status
- new
- Section
- [rand.req.urng]
- Submitter
- Casey Carter

Created on **2018-08-09.00:00:00**,
last changed **2018-08-20.12:41:52**.

Date: 2018-08-20.12:41:52

**Proposed resolution:**

This wording is relative to N4762.

Modify [rand.req.urng] as follows:

1 A

*uniform random bit generator*`g`of type`G`is a function object returning unsigned integer values such that each value in the range of possible results has (ideally) equal probability of being returned. [*Note:*The degree to which`g`'s results approximate the ideal is often determined statistically.—*end note*]template<auto> struct

*require-constant*; //*exposition-only*template<class G> concept UniformRandomBitGenerator = Invocable<G&> && UnsignedIntegral<invoke_result_t<G&>> && requires { G::min(); requires Same<decltype(G::min()), invoke_result_t<G&>>; G::max(); requires Same<decltype(G::max()), invoke_result_t<G&>>; typename*require-constant*<G::min()>; typename*require-constant*<G::max()>; requires G::min() < G::max(); };2 Let

`g`be an object of type`G`.`G`models`UniformRandomBitGenerator`only if~~(2.1) — both~~`G::min()`and`G::max()`are constant expressions ([expr.const]),~~(2.2) —~~`G::min() < G::max()`,(2.3) —

`G::min() <= g()`,(2.4) —

`g() <= G::max()`, and(2.5) —

`g()`has amortized constant complexity.3 A class

`G`meets the*uniform random bit generator*requirements if`G`models`UniformRandomBitGenerator`,`invoke_result_t<G&>`is an unsigned integer type ([basic.fundamental]), and`G`provides a nested*typedef-name*`result_type`that denotes the same type as`invoke_result_t<G&>`.

Date: 2018-08-20.00:00:00

*[ 2018-08-20 Priority set to 3 after reflector discussion ]*

Date: 2018-08-09.00:00:00

[rand.req.urng]
paragraph 2 specifies axioms for
the `UniformRandomBitGenerator` concept:

2 Let

gbe an object of typeG.GmodelsUniformRandomBitGeneratoronly if(2.1) — both

G::min()andG::max()are constant expressions ([expr.const]),(2.2) —

G::min() < G::max(),(2.3) —

G::min() <= g(),(2.4) —

g() <= G::max(), and(2.5) —

g()has amortized constant complexity.

Bullets 2.1 and 2.2 are both compile-time requirements that ought to be validated by the concept.

History | |||
---|---|---|---|

Date | User | Action | Args |

2018-08-20 12:41:52 | admin | set | messages: + msg10079 |

2018-08-09 00:00:00 | admin | create | |

2018-08-08 23:43:13 | admin | set | messages: + msg10055 |