An earlier post looked at random shuffle
for permutations. The STL also supports creation of random samples.
Alas, it seems that this functionality has not been promoted to the
C++ standard yet — so we will have to do with what is an
extensions by the GNU g++ compiler.
The other drawback is the sampling without replacement.
As in the previous post, we use a function object conformant to the
STL’s requirements for a random number generator to be able to use
R’s RNG.