The correct way to do a shuffle is to choose a random other index to fill in the current index, which is uniform:

  Also, you may need a uniform random generator in C++: