The STL also contains random sampling and shuffling algorithms.
We start by looking at random_shuffle.

There are two forms. The first uses an internal RNG with its own
seed; the second form allows for a function object conformant to
the STL’s requirements (essentially, given N produce a uniform
draw greater or equal to zero and less than N). This is useful
for us as it lets us tie this to the same RNG which R uses.

We can illustrate this on a simple example or two:

[1] 1 4 3 7 5 8 6 2

[1] 1 4 3 7 5 8 6 2

By tieing the STL implementation of the random permutation to the
RNG from R, we are able to compute reproducible permutations, fast
and from C++.