Reputation: 259
Hi I have a function which takes std::vector<T>::const_iterator
as parameter.
Question is:
How can I cast standalone object of type T, into iterator, so I can use it as an argument?
Upvotes: 0
Views: 141
Reputation: 347
You shouldn't be trying to cast an arbitrary object type T to std::vector::const_iterator
.
Assuming the object is a std::vector<T>
, you can use the std::vector::cbegin
or std::vector::cend
functions to get a std::vector::const_iterator
.
Upvotes: 0
Reputation: 1
"How can I cast standalone object of type T, into iterator, so I can use it as an argument?"
You cannot. That standalone object needs to be stored in an appropriate container. Only containers provide creation of iterators.
Upvotes: 3