Use empty() instead of begin() == end().