Do not throw in loop, return std::numeric_limits::max