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

后端 未结 8 648
无人共我
无人共我 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:05

    I would be surprised and disappointed in myself to learn that any of the C++ code I wrote in the last 12 years had this sort of problem. But most compilers would have spewed warnings about any compile-time "narrowings" all along, unless I'm missing something.

    Are these also narrowing conversions?

    unsigned short b[] = { -1, INT_MAX };
    

    If so, I think they might come up a bit more often than your floating-type to integral-type example.

提交回复
热议问题