I have a vector: vector<Turret> turrets; and I have filled it with Turret objects. I have a pointer vector<Turret>::pointer ptr = &turrets[0];
I know that if the size of the turrets vector shrinks to 0, the pointer is invalid, so how do I tell when the size is 0? (My pointer points to the first element, so I can't use turrets.size().)
Kinda confused as to how I would make sure that the vector isn't empty b/c I don't want my pointer to be invalid and me not know.
Are you sure that pointer thing is standard? I can't seem to find it in the reference and I've never seen it before.
If that works like the actual pointer, then there's no way of knowing the size of the vector [[the object it points to] is in], since there's no context information.
If you need to know the size of the vector, why not just pass a pointer or reference to the vector?