Consider this code:
struct CData
{
int bar() { return 1; }
};
int main()
{
typedef boost::numeric::ublas::vector<CData> vec_data_t;
vec_data_t foo;
for (vec_data_t::iterator it = foo.begin();
it != foo.end();
++it)
{
std::cout << it->bar() << std::endl; // COMPILE ERROR!
std::cout << (*it).bar() << std::endl; // ok
}
return 0;
}
Why does the first line in the loop using the arrow operator fail to compile, while the next line using operator* works fine? I'm used to using the arrow operator with std container iterators and wonder why it fails with boost::numeric::ublas iterators.
I'm using boost 1.54 and gcc 4.9.1 and the exact error message is:
error: base operand of ‘->’ has non-pointer type ‘boost::numeric::ublas::vector<CData>::iterator’