c++ - What is the correct way to articulate programmer intent with an implicit truncating downcast? -
given code following:
int32_t = big value; int16_t x = a;
i believe best practices suggest allowing compiler perform implicit cast int32_t int16_t. in code sense more clear:
int16_t x = static_cast<int16_t>( );
is "correct" or verbose? goal ensure future readers understand deliberate nature of truncation.
the reason inquire question code filled tons of explicit casts purely clarity, understand sick advised.
c++ casting styles
No comments:
Post a Comment