I'd prefer std::min from algorithm here but I'll defer to @acmorrow