问题
I am working on a c++ program with a set of sets. Here is the declared set of sets.
std::set< std::set<int> > temp_moves;
I am getting the error below in this declaration, my question is that is my syntax correct? is it possible to create a set of sets in programs?
error: no matching function for call to ‘std::set<std::set<int> >::insert(int&)’
Updated Code
std::set<int> next_moves;
std::set<int> available_numbers;
for (const auto available_number : available_numbers)
temp_moves.insert(number);
temp_moves.insert(available_number);
next_moves.insert(temp_moves);
回答1:
You are inserting an integral value available_number into a data structure temp_moves that expects a set...
Probably not the logic that you want to achieve, but the following will at least compile. Hope it helps somehow:
std::set<int> next_moves;
std::set<int> available_numbers;
for (const auto available_number : available_numbers) {
next_moves.insert(available_number);
}
temp_moves.insert(next_moves);
来源:https://stackoverflow.com/questions/47253499/declaring-set-of-sets-with-integer-in-c