Apr 13, 2011 at 8:13pm UTC
Hello,
Can anybody PLEASE help me? I want to read each element of a std::vector <std::vector <TVector3> > obj1;
Here is what I am doing;
for(int i=0; i<obj1.size(); i++){
for(std::vector<TVector3>::iterator itr = obj1[i].begin(); itr =obj1[i].end(); ++itr){
(*itr).Print();
}
std::cout << "*******" << std::endl;
}
When I do above I get the error message as follows;
error: could not convert ‘(itr <unknown operator> ((const __gnu_cxx::__normal_iterator<TVector3*, std::vector<TVector3> >&)((const __gnu_cxx::__normal_iterator<TVector3*, std::vector<TVector3> >*)(&((std::vector<TVector3>*)vertexcand_vec.std::vector<_Tp, _Alloc>::operator[] [with _Tp = std::vector<TVector3>, _Alloc = std::allocator<std::vector<TVector3> >, std::vector<_Tp, _Alloc>::reference = std::vector<TVector3>&, std::vector::size_type = long unsigned int](((long unsigned int)i)))->std::vector<_Tp, _Alloc>::end [with _Tp = TVector3, _Alloc = std::allocator<TVector3>, std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<TVector3*, std::vector<TVector3> >, typename std::vector<_Tp, _Alloc>::_Base::_Tp_alloc_type::pointer = TVector3*]()))))’ to ‘bool’
Please help. Thank You.
Apr 13, 2011 at 8:32pm UTC
Are you trying to pack one vector inside of another? I guess I don't understand what a "TVector3" data type is. Link?
Apr 13, 2011 at 8:34pm UTC
This
itr =obj1[i].end();
should be
itr != obj1[i].end();
Apr 13, 2011 at 8:41pm UTC
Oh, so it was a typo in my code, Sorry I could not see it. It works when I replaced itr =obj1[i].end();
with
itr != obj1[i].end();
Thanks.
Apr 13, 2011 at 8:51pm UTC
Just notice that, unreadable as they may seem, template error messages sometimes can be read. The above message says "could not convert foo to bool" if you ignore the messy part. Then you just have to look for boolean expressions.