mardi 5 avril 2016

How can i write, "if not greater than or equal to some value" eloquently?

I am reading, Programming: Principle and Practice Using C++, and Bjarne suggest avoiding overuse of parentheses. Is there an eloquent way to structure the following if statement? Here is my code:

bool is_valid(string s)
{
      if(!(s.size()>=8)) throw invalid_argument("Username must be 8 char or more");
      return true;
}

Aucun commentaire:

Enregistrer un commentaire