I would like to check if the iterator (or similar types) precedes the other. In this example, I would like to verify that I do not have an infinite loop. This means that "if I apply the ++ operator enough time to start, I will come to an end." Is this possible in C ++ 98? Maybe with a restriction on type T?
template <typename T>
void loop(const T& begin, const T& end)
{
T run = begin;
while(run != end)
{
++run;
}
}
loop(0,10);
std::set<double> x;
x.insert(1.0);
x.insert(2.0);
x.insert(3.0);
loop(x.begin(), x.end());
source
share