You can use the Boost Permutation Iterator or use OpenCV's randShuffle() (there is an example of how to use it in the samples under samples\cpp\kmeans.cpp).