C++ "var foo = !!::bar()" syntax ? [duplicate]
Asked Answered
M

1

8

Looking for some explanation on how going fullscreen mode with HWND window, I found this response Win32: full-screen and hiding taskbar

The chromium response code has this 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 this correct ?

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

Why not just

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

?

Miserable answered 24/4, 2017 at 9:58 Comment(1)
!! is used to transform any non-zero value into a boolean true / false. some compillers can be quite picky.Electrostatic
M
10

The !! is simply ! and !, two negations. Double negation reduces to noop, but it casts the value to bool. So consider that an alternative syntax to (bool). It's advantage is that it:

  1. it works in C which did not have a separate bool type in C89 (forces the value of 0 or 1) and
  2. MSC++ does not generate the silly “performance warning” for it like it does for (bool).

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

Mungovan answered 24/4, 2017 at 10:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.