Annex D (normative) Compatibility features [depr]

D.12 Random shuffle [depr.alg.random.shuffle]

The function templates random_shuffle are deprecated.

template<class RandomAccessIterator> void random_shuffle(RandomAccessIterator first, RandomAccessIterator last); template<class RandomAccessIterator, class RandomNumberGenerator> void random_shuffle(RandomAccessIterator first, RandomAccessIterator last, RandomNumberGenerator&& rng);

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

Requires: RandomAccessIterator shall satisfy the requirements of ValueSwappable ([swappable.requirements]). The random number generating function object rng shall have a return type that is convertible to iterator_traits<RandomAccessIterator>::difference_type, and the call rng(n) shall return a randomly chosen value in the interval [0,n), for n > 0 of type iterator_traits<RandomAccessIterator>::difference_type.

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

Remarks: To the extent that the implementation of these functions makes use of random numbers, the implementation shall use the following sources of randomness:

The underlying source of random numbers for the first form of the function is implementation-defined. An implementation may use the rand function from the standard C library.

In the second form of the function, the function object rng shall serve as the implementation's source of randomness.