25 Algorithms library [algorithms]

25.6 Mutating sequence operations [alg.modifying.operations]

25.6.13 Shuffle [alg.random.shuffle]

template<class RandomAccessIterator, class UniformRandomBitGenerator> void shuffle(RandomAccessIterator first, RandomAccessIterator last, UniformRandomBitGenerator&& g); template<RandomAccessIterator I, Sentinel<I> S, class Gen> requires Permutable<I> && UniformRandomBitGenerator<remove_reference_t<Gen>> I ranges::shuffle(I first, S last, Gen&& g); template<RandomAccessRange R, class Gen> requires Permutable<iterator_t<R>> && UniformRandomBitGenerator<remove_reference_t<Gen>> safe_iterator_t<R> ranges::shuffle(R&& r, Gen&& g);
Requires: For the overload in namespace std:
Effects: Permutes the elements in the range [first, last) such that each possible permutation of those elements has equal probability of appearance.
Returns: last for the overloads in namespace ranges.
Complexity: Exactly (last - first) - 1 swaps.
Remarks: To the extent that the implementation of this function makes use of random numbers, the object referenced by g shall serve as the implementation's source of randomness.