Each element in the input range appears at most once in the output range, and samples are chosen with uniform probability. The first version uses an internal random number generator, and the second uses a Random Number Generator , a special kind of function object , that is explicitly passed as an argument. Definition Defined in the standard header algorithm , and in the nonstandard backward-compatibility header algo.h .
Distance is an integral type that is large enough to represent the value last - first .
ForwardIterator 's value type is convertible to a type in OutputIterator 's set of value types. Distance is convertible to RandomNumberGenerator 's argument type. There is enough space to hold all of the elements being copied. Complexity Linear in last - first . Seminumerical Algorithms , second edition.