### 2168. Inconsistent specification of `uniform_real_distribution` constructor

**Section:** 29.6.8.2.2 [rand.dist.uni.real] **Status:** C++17
**Submitter:** Marshall Clow **Opened:** 2012-07-14 **Last modified:** 2017-07-30

**Priority: **3

**View all issues with** C++17 status.

**Discussion:**

uniform_real says in 29.6.8.2.2 [rand.dist.uni.real] p1:

A `uniform_real_distribution` random number distribution produces random numbers `x`, `a ≤ x < b`,

but also that (29.6.8.2.2 [rand.dist.uni.real] p2):

explicit uniform_real_distribution(RealType a = 0.0, RealType b = 1.0);

-2- *Requires*: `a ≤ b` and `b - a ≤ numeric_limits<RealType>::max()`.

If you construct a `uniform_real_distribution<RealType>(a, b)` where there are no representable
numbers between 'a' and 'b' (using `RealType`'s representation) then you cannot satisfy
29.6.8.2.2 [rand.dist.uni.real].

An obvious example is when `a == b`.

*[2014-11-04 Urbana]*

Jonathan provides wording.

*[2014-11-08 Urbana]*

Moved to Ready with the note.

There remains concern that the constructors are permitting
values that may (or may not) be strictly outside the domain
of the function, but that is a concern that affects the
design of the random number facility as a whole, and should
be addressed by a paper reviewing and addressing the whole
clause, not picked up in the issues list one distribution
at a time. It is still not clear that such a paper would be
uncontroversial.

**Proposed resolution:**

This wording is relative to N4140.

Add a note after paragraph 1 before the synopsis in 29.6.8.2.2 [rand.dist.uni.real]:

-1- A `uniform_real_distribution` random number distribution produces random numbers
$x$,
$a\le x<b$,
distributed according to the constant probability density function

$p\left(x\right|a,b)=1\u2215(b-a)$
.

[*Note*: This implies that $p\left(x\right|a,b)$ is undefined when `a == b`. — *end note*]

*Drafting note*: $p\left(x\right|a,b)$ should be in math font, and `a == b` should be in code font.