C ++ syntax "var foo = !! :: bar ()"?

Looking for some explanation on how to switch to fullscreen mode with the HWND window, I found this Win32 answer : fullscreen and hiding the taskbar

The chrome response code has the following line:

saved_window_info_.maximized = !!::IsZoomed(hwnd_); 

from this file https://src.chromium.org/viewvc/chrome/trunk/src/ui/views/win/fullscreen_handler.cc?revision=HEAD&view=markup on line 56

I read:

 var bar equal not not of mother method 

Is it correct?

What does this mean? !! :: IsZoomed () "means?

Why not just

 saved_window_info_.maximized = CWnd::IsZoomed(hwnd_); 

?

+7
c ++ syntax cwnd
source share
1 answer

!! - it's easy ! and ! , two negatives. Double negation comes down to noop, but it distinguishes the value of bool . Therefore, consider the alternative syntax (bool) . The advantage is that it:

  • it works in C, which does not have a separate bool type in C89 (forces a value of 0 or 1) and
  • MSC ++ does not generate a stupid "performance warning" for it, nor for (bool) .

And the rest is just ::IsZoomed , i.e. IsZoomed function from the top-level namespace.

+10
source share

All Articles