Я пытаюсь создать класс контейнера для boost :: ptr_vector и им просто немного неприятно заставить итератор работать.
вот одна из функций-членов, которую я пытаюсь реализовать:
//data is of type boost::ptr_vector<T>
//Date is a custom date class that i made with > operator overloaded
template <class T>
void P_VContainer<T>::addElementByDate(T* item)
{
boost::ptr_vector<T>::iterator it;
for(it = data.begin(); it < data.end(); it++)
{
T temp = *it;
Date = *lhs = item->getDate();
Date = *rhs = item.getDate();
if(*lhs > *rhs)
{
data.insert(it, item);
return;
}
}
data.insert(it, item);
}
ошибка, которую я получаю:
p_vcontainer.cpp: In member function ‘void P_VContainer<T>::addElementByDate(T*):
p_vcontainer.cpp:52:2: error: need ‘typename before ‘boost::ptr_vector<T>::iterator because ‘boost::ptr_vector<T> is a dependent scope
p_vcontainer.cpp:52:33: error: expected ‘; before ‘it
p_vcontainer.cpp:54:7: error: ‘it was not declared in this scope
любые идеи о том, как это исправить?
Капитан Очевидный на помощь!
требуется "typename before" boost :: ptr_vector :: iterator
write typename boost::ptr_vector<T>::iterator it;