11 Algorithms library [algorithms]

11.4 Mutating sequence operations [alg.modifying.operations]

11.4.12 Shuffle [alg.random.shuffle]

template <RandomAccessIterator I, Sentinel<I> S, class Gen> requires Permutable<I> && UniformRandomNumberGenerator<remove_reference_t<Gen>> && ConvertibleTo<result_of_t<Gen&()>, difference_type_t<I>> I shuffle(I first, S last, Gen&& g); template <RandomAccessRange Rng, class Gen> requires Permutable<I> && UniformRandomNumberGenerator<remove_reference_t<Gen>> && ConvertibleTo<result_of_t<Gen&()>, difference_type_t<I>> safe_iterator_t<Rng> shuffle(Rng&& rng, Gen&& g);

Effects: Permutes the elements in the range [first,last) such that each possible permutation of those elements has equal probability of appearance.

Complexity: Exactly (last - first) - 1 swaps.

Returns: last

Remarks: To the extent that the implementation of this function makes use of random numbers, the object g shall serve as the implementation's source of randomness.