Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

syntax

cwnd

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_);

?

like image 521
Julien hadim Avatar asked Apr 24 '17 09:04

Julien hadim


1 Answers

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.

like image 199
Jan Hudec Avatar answered Sep 30 '22 00:09

Jan Hudec