Use std::advance rather than a loop and increment.

This commit is contained in:
Tsuda Kageyu 2015-05-18 09:31:43 +09:00
parent c2570fe115
commit 6e40361c0e

View File

@ -266,9 +266,7 @@ template <class T>
T &List<T>::operator[](uint i)
{
Iterator it = d->list.begin();
for(uint j = 0; j < i; j++)
++it;
std::advance(it, i);
return *it;
}
@ -277,9 +275,7 @@ template <class T>
const T &List<T>::operator[](uint i) const
{
ConstIterator it = d->list.begin();
for(uint j = 0; j < i; j++)
++it;
std::advance(it, i);
return *it;
}