unknown statement

hi together,

in a source code i found the following:
1
2
3
4
bool Logger::Success(const char* msg)
{
   return !! LogSuccess(LogObj, msg)
}


So what ist this " !! " all about...
Has anyone seen this before in C++-Std?

Thx DG
My guess would be that it is effectivly typecasting LogSuccess(LogObj, msg) to bool.
I woudl imagine LogSuccess() returns an integer type, so !LogSucess() will implicitly typecast this to a bool as part of the not operation.
!!LogSuccess() is not(not (LogSuccess() ) ), IE LogSuccess typecast to bool.

And it's totally pointless in this case since Logger::Success() returns bool.

It's a shorthand trick that allows programmers to convert zero to zero and non-zero to one, but it is only applicable when the required end result is int (in the above case it is bool).
Topic archived. No new replies allowed.