In the sample code here it shows cases how to use std::sample as shown below
std::string in = "hgfedcba", out;
std::sample(in.begin(), in.end(), std::back_inserter(out),
5, std::mt19937{std::random_device{}()});
std::cout << "five random letters out of " << in << " : " << out << '\n';
Possible output:
five random letters out of hgfedcba: gfcba
My question is not only I want gfcba I also want to extract the remaining elements that are the not sampled, e.g. hed. I know I can write a for loop to compare in and out to extract the remaining elements, but I am wondering if there's a more efficient way to do this.