```
template<class PopulationIterator, class SampleIterator,
class Distance, class UniformRandomBitGenerator>
SampleIterator sample(PopulationIterator first, PopulationIterator last,
SampleIterator out, Distance n,
UniformRandomBitGenerator&& g);
```

Preconditions:

- PopulationIterator meets the Cpp17InputIterator requirements ([input.iterators]).
- SampleIterator meets the Cpp17OutputIterator requirements ([output.iterators]).
- SampleIterator meets the Cpp17RandomAccessIterator requirements ([random.access.iterators]) unless PopulationIterator meets the Cpp17ForwardIterator requirements ([forward.iterators]).
- remove_reference_t<UniformRandomBitGenerator> meets the requirements of a uniform random bit generator type ([rand.req.urng]).
- out is not in the range [first, last).

Effects:
Copies elements (the *sample*)
from [first, last) (the *population*) to out
such that each possible sample has equal probability of appearance.

[ Note

: â€” *end note*

]