Commit 3a096469 authored by Davis King's avatar Davis King
Browse files

Changed code to avoid advancing iterator beyond end since some compilers

complain about this (and it's technically not allowed in C++).
parent edb2790b
...@@ -2189,10 +2189,15 @@ namespace dlib ...@@ -2189,10 +2189,15 @@ namespace dlib
{ {
std::vector<label_type> results(std::distance(data.begin(), data.end())); std::vector<label_type> results(std::distance(data.begin(), data.end()));
auto o = results.begin(); auto o = results.begin();
for (auto i = data.begin(); i < data.end(); i+=batch_size, o+=batch_size) auto i = data.begin();
{ auto num_remaining = results.size();
auto end = std::min(i+batch_size, data.end()); while(num_remaining != 0)
(*this)(i, end, o); {
auto inc = std::min(batch_size, num_remaining);
(*this)(i, i+inc, o);
i += inc;
o += inc;
num_remaining -= inc;
} }
return results; return results;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment