Iterating PointerToArray with type LVecBase4f

Hi all,

While trying to iterate through a container of type LVecBase4f like this:

...
PointerToArray<LVecBase4f> core_colour_data;
PTA_LVecBase4f::iterator it;
for(it=core_colour_data.begin();it!=core_colour_data.end();it++)
{
...
}
...

I get this error:

error C2679: binary '=': no operator found which takes a right-hand operand of type 'std::_Vector_iterator<std::_Vector_val<std::_Simple_types<LVecBase4f>>>' (or there is no acceptable conversion)

Doing the exact same thing with type LVecBase2i however works fine with no errors. Is it that the “=” operator isn’t implemented for a container with type LVecBase4f and so I’d have to use: PointerToArray<float> as a workaround to PointerToArray<LVecBase4f> , or am I missing something else instead?

Thanks in advance.

PTA_LVecBase4f is actually defined as PointerToArray<UnalignedLVecBase4f> (for mostly historical reasons), so you’re using mismatching types. Either use one or the other.

Note that you can also use the C++11-style iteration syntax:

...
PointerToArray<LVecBase4f> core_colour_data;
for(LVecBase4f &item : core_colour_data)
{
...
}
...

Thanks for the clarification, doing this for example:

PointerToArray<UnalignedLVecBase4f> core_colour_data;
UnalignedLVecBase4f data_set_4(LVecBase4f(0.455,0.677,0.009,0.344));
core_xz4ddata.push_back(data_set_4);
PTA_LVecBase4f::iterator it;
it=core_xz4ddata.begin();
UnalignedLVecBase4f data_set_4ii(LVecBase4f(0.144355,0.2677,0.6009,0.7344));
core_xz4ddata.insert(it,data_set_4ii);

Works fine now. I also needed the iterator in order to insert and erase elements from the container.