samedi 30 avril 2016

How to iterate over values when std::vector::data is given

I have a function that returns in the following format:

 const value_type* data() const { return data_.data(); } 

At the place from the call is placed. I am trying to iterate over the values. But unable to figure as how to get an iterator when pointer to the first element in the array used internally by the vector is given.

Calling side:

for (auto y:X.data()) std::cout << y << " " <<std::endl;

But getting an

error: invalid range expression of type 'const int *'; no viable 'begin' function available

Aucun commentaire:

Enregistrer un commentaire