C ++ cast into the void
As I understand it, the C ++ standard says that casting to void is correct only in the case of function-style casting (ISO / IEC 14882: 2003, 5.2.3).
But I can't find anything about how C-style casting void is in the C ++ standard.
Is the program behavior just implementation in this case?
source to share
As I understand it, the C ++ standard says that the cast to
void
is correct only in the case of function-style casting
No, it can be done with static_cast
, and therefore also with, conversions using functional or cast designations.
But I can't find anything about the C style being different from
void
in the C ++ standard.
It is defined for static_cast
in [expr.static.cast], 5.2.9 / 6:
Any expression can be explicitly converted to type cv
void
, in which case it becomes the discarded value of the expression.
[expr.cast], 5.4, describes how C-style casting can use static_cast
, so it is also valid for that style. [expr.type.conv], 5.2.3, describes how the functional style is equivalent to the C style, so it is also valid for that style.
(Note: section numbers refer to C ++ 11 (ISO / IEC 14882: 2011), not the C ++ 03 you are linking to, as the current version. Other versions may differ, but maybe a lot.) >
source to share