maxpayne
maxpayne

Reputation: 1111

What does this "return ~Result(0)" mean in C++?

I have never seen this before... just curious to know what "return ~Result(0)" does.

Simple::Result Screen::pickPoint(const Point& Point) const
    {

    if(scnr.hasPoint())
        return scnr.getIndex();
    else
        return ~Result(0);
    }

Upvotes: 0

Views: 334

Answers (1)

phantom
phantom

Reputation: 3342

Assuming that Simple::Result has overloaded the bitwise not operator (~). This will call the overloaded operator in the Simple::Result class and return the result.

If the ~ operator performs a bitwise not operation, that function should return a Simple::Result that is all 1s (in binary) when scnr.hasPoint returns false.

You can read more about the bitwise not operator here.

Upvotes: 2

Related Questions