Cześć.
Staram się ogarnąć, czy da się zmienić wartość iteratora bezpośrednio lub prawie-bezpośrednio (ze strony użytkowej), napisałem coś takiego:
#include <utility>
#include <vector>
...
template <typename T>
inline size_t itVal(std::vector<Type> vec, std::vector<Type>::iterator it){
return std::distance(vec.begin(), it);
}
template<typename T>
void set_iter(std::vector<T> vec, std::vector<T>::iterator it, size_t val){
size_t it_val = itVal<T>(vec, it);
while(it_val!=val){
it_val = itVal(vec, it);
it_val<val ? it++ : it--;
}
}
...
Dostaję takie errory (onlinegdb, C++17):
main.cpp:6:44: error: ‘std::vector >::iterator’ is not a type
inline size_t itVal(std::vector<Type> vec, std::vector<Type>::iterator it){
^~~
main.cpp:12:35: error: ‘std::vector >::iterator’ is not a type
void set_iter(std::vector<T> vec, std::vector<T>::iterator it, size_t val){
... (no matching blah blah)
Zastanawia mnie tylko, dlaczego nie jest to typ i co mogę w tej sytuacji zrobić, żeby zachować aktualną strukturę.
Z góry dzięki za pomoc.
//EDIT
Kierując się tym dodałem typename przed i problemu nie ma, ale dlaczego?