Loop through vector

Mar 13, 2019 at 5:48pm
I want to loop through this vector:

 
  std::vector<DynamicSdmProtocol::DynamicSdm*>  m_devices;


I am getting an error when trying to loop through it in the following way:

 
for (int i = 0; i < m_devices.size(); ++i)


the error is:
no matching function for call to 'std::vector<DynamicSdmProtocol::DynamicSdm*, std::allocator<DynamicSdmProtocol::DynamicSdm*> >::size(int)'

what should my upper bound be if not the size of the vector?
Mar 13, 2019 at 5:54pm
From the error message it looks like you are trying to pass an integer as argument to the size() function.
Mar 13, 2019 at 5:55pm
size is correct.
it looks like its having trouble finding size() ... does it need a std:: or something?
alternatively, have you been able to use the vector before this loop, to populate it or anything, and that works?
Last edited on Mar 13, 2019 at 5:56pm
Mar 13, 2019 at 5:56pm
Ah I see now, this was my fault, size() is correct.
Topic archived. No new replies allowed.