Thanks, just as I started this discussion I thought of that but didn't have time to try it.
I've tried three apporaches but none of them seem quite right.
My initaial thoughts where
std::set<std::vector<int>,Compare>::iterator it;
for( it = combinations.begin(); it != combinations.end(); it++ ) {
std::vector<int>::iterator it2;
for ( it2 = it->begin(); it2 != it->end(); ++it2 ){
std::cout << *it2 << std::endl;
}
which failed on
$ make
g++ -c -O -g combo.cpp main.cpp
combo.cpp: In member function ‘int Combo::printCombinations()’:
combo.cpp:26:27: error: no match for ‘operator=’ in ‘it2 = it.std::_Rb_tree_const_iterator<_Tp>::operator-> [with _Tp = std::vector<int>, std::_Rb_tree_const_iterator<_Tp>::pointer = const std::vector<int>*]()->std::vector<_Tp, _Alloc>::begin [with _Tp = int, _Alloc = std::allocator<int>, std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >, typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::const_pointer = const int*]()’
So I thougt, "Ah, itterator it needs to be derefferenced. This will give me the vector<int> which I can then find the start and finish iterators of the vector!"
std::set<std::vector<int>,Compare>::iterator it;
for( it = combinations.begin(); it != combinations.end(); it++ ) {
std::vector<int>::iterator it2;
for ( it2 = (*it).begin(); it2 != (*it).end(); ++it2 ){
std::cout << *it2 << std::endl;
}
}
Also a fail with the same compiler message.
So then out of desperation I tried something which I didn't expect to work.
std::set<std::vector<int>,Compare>::iterator it;
for( it = combinations.begin(); it != combinations.end(); it++ ) {
std::vector<int>::iterator it2;
for ( it2 = (*it)->begin(); it2 != (*it)->end(); ++it2 ){
std::cout << *it2 << std::endl;
}
}
and got this error, which supprises me less.
make
g++ -c -O -g combo.cpp main.cpp
combo.cpp: In member function ‘int Combo::printCombinations()’:
combo.cpp:26:22: error: base operand of ‘->’ has non-pointer type ‘const std::vector<int>’
combo.cpp:26:45: error: base operand of ‘->’ has non-pointer type ‘const std::vector<int>’
main.cpp: In function ‘int main(int, char**)’:
main.cpp:27:3: error: expected ‘;’ before ‘exit’
make: *** [main.o] Error 1
Can someone offer me some illumination please.