dimanche 19 mai 2019

How can this if statement be simplified?

I am using CLion IDE to code my C++ project. Sometimes it happens that the IDE tries to be more intelligent than me and gives me suggestions. I have a simple problem during code inspection (by CLion). It says the following code can be simplified, even though I believe it is the most simple form I can think of :

Code :

    if (node.first >= 0 && node.first <= 45 &&
    node.second >= 0 && node.second <= 30)
    return true;

Assume node is of type std::pair<int, int>

The suggestion I get from the CLion IDE is the following:

Code Inspection comments :

Inspection info: This inspection finds the part of the code that can be simplified, e.g. constant conditions, identical if branches, pointless boolean expressions, etc.

Do you think this can be simplified more ?

Aucun commentaire:

Enregistrer un commentaire