[#absl-Uniform-0e2]
= xref:absl.adoc[absl]::Uniform
:relfileprefix: ../
:mrdocs:

Produces random values of type `T` uniformly distributed in an interval&period;

== Synopsis

Declared in `&lt;absl&sol;random&sol;distributions&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    typename R = void,
    typename TagType,
    typename URBG&gt;
R
Uniform(
    TagType tag,
    URBG&& urbg,
    R lo,
    R hi)
requires !std&colon;&colon;is&lowbar;same&lowbar;v&lt;R, void&gt;;
----

== Description

`absl&colon;&colon;Uniform()` produces random values of type `T` uniformly distributed in a defined interval &lcub;lo, hi&rcub;&period; The interval `tag` defines the type of interval which should be one of the following possible values&colon;

&ast; `absl&colon;&colon;IntervalOpenOpen` &ast; `absl&colon;&colon;IntervalOpenClosed` &ast; `absl&colon;&colon;IntervalClosedOpen` &ast; `absl&colon;&colon;IntervalClosedClosed`

where &quot;open&quot; refers to an exclusive value (excluded) from the output, while &quot;closed&quot; refers to an inclusive value (included) from the output&period;

In the absence of an explicit return type `T`, `absl&colon;&colon;Uniform()` will deduce the return type based on the provided endpoint arguments &lcub;A lo, B hi&rcub;&period; Given these endpoints, one of &lcub;A, B&rcub; will be chosen as the return type, if a type can be implicitly converted into the other in a lossless way&period; The lack of any such implicit conversion between &lcub;A, B&rcub; will produce a compile&hyphen;time error

See https&colon;&sol;&sol;en&period;wikipedia&period;org&sol;wiki&sol;Uniform&lowbar;distribution&lowbar;(continuous)

Example&colon;

absl&colon;&colon;BitGen bitgen&semi;

&sol;&sol; Produce a random float value between 0&period;0 and 1&period;0, inclusive auto x &equals; absl&colon;&colon;Uniform(absl&colon;&colon;IntervalClosedClosed, bitgen, 0&period;0f, 1&period;0f)&semi;

&sol;&sol; The most common interval of `absl&colon;&colon;IntervalClosedOpen` is available by &sol;&sol; default&colon;

auto x &equals; absl&colon;&colon;Uniform(bitgen, 0&period;0f, 1&period;0f)&semi;

&sol;&sol; Return&hyphen;types are typically inferred from the arguments, however callers &sol;&sol; can optionally provide an explicit return&hyphen;type to the template&period;

auto x &equals; absl&colon;&colon;Uniform&lt;float&gt;(bitgen, 0, 1)&semi;

== Return Value

A random value uniformly distributed in the interval&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *tag*
| The interval tag selecting which endpoints are included&period;
| *urbg*
| The uniform random bit generator&period;
| *lo*
| The lower bound of the interval&period;
| *hi*
| The upper bound of the interval&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
