Unit-test shows the following use-case: auto a = ([ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]).dup; Mt19937 gen; randomShuffle(a, gen); As a side note I'd add that you should better use Random instead of Mt19937 (the former being an alias to the latter), because it is easier to read and understand (I bet too many people exclaim "wtf is that??" when they first see a class named "Mt19937").