How to use random _shuffle(), to pair up object/instance using its string attribute? Thanks in advance!
void game1(void)
{
srand(time(nullptr));
const set<string> values{ }; //I don't know how to add my string //attribute here
for (auto pair : make_unique_pairs(values))
cout << pair.first << ',' << pair.second << '\n';
}
void main()
template < typename T >
vector< pair<T, T> > make_unique_pairs(const set<T>& set)
{
vector< pair<T, T> > result;
// make a vector of references to elements in the set
vector< reference_wrapper< const T > > seq(set.begin(), set.end());
// make a random permutation of the references
random_shuffle(begin(seq), end(seq));
// make pairs and place them into the result
for (size_t i = 0; i < seq.size() - 1; i += 2)
result.emplace_back(seq[i], seq[i + 1]);
return result;
}