Narrowing conversions in C++0x. Is it just me, or does this sound like a breaking change?

后端 未结 8 651
无人共我
无人共我 2020-11-27 14:21

C++0x is going to make the following code and similar code ill-formed, because it requires a so-called narrowing conversion of a double to a int<

8条回答
  •  时光说笑
    2020-11-27 15:14

    A practical instance that I have encountered:

    float x = 4.2; // an input argument
    float a[2] = {x-0.5, x+0.5};
    

    The numeric literal is implicitly double which causes promotion.

提交回复
热议问题