void
used to suppress compiler warnings for unused variables and unsaved return values or expressions.
The standard (2003) states that paragraph 5.2.9 / 4 states:
Any expression can be explicitly converted to type "cv void". The value of the expression is selected .
So you can write (in C ++ style):
//suppressing unused variable warnings static_cast<void>(unusedVar); //suppressing return value warnings static_cast<void>(fn()); //suppressing unsaved expressions static_cast<void>(a + b * 10); static_cast<void>( x &&y || z); static_cast<void>( m | n + fn());
All forms are valid. I usually do this shorter:
Its good too.
source share