Note that there are some explanatory texts on larger screens.

plurals
  1. PONarrowing conversions in C++0x. Is it just me, or does this sound like a breaking change?
    primarykey
    data
    text
    <p>C++0x is going to make the following code and similar code ill-formed, because it requires a so-called <em>narrowing conversion</em> of a <code>double</code> to a <code>int</code>. </p> <pre><code>int a[] = { 1.0 }; </code></pre> <p>I'm wondering whether this kind of initialization is used much in real world code. How many code will be broken by this change? Is it much effort to fix this in your code, if your code is affected at all?</p> <hr> <p>For reference, see 8.5.4/6 of n3225</p> <blockquote> <p>A narrowing conversion is an implicit conversion</p> <ul> <li>from a floating-point type to an integer type, or</li> <li>from long double to double or float, or from double to float, except where the source is a constant expression and the actual value after conversion is within the range of values that can be represented (even if it cannot be represented exactly), or</li> <li>from an integer type or unscoped enumeration type to a floating-point type, except where the source is a constant expression and the actual value after conversion will fit into the target type and will produce the original value when converted back to the original type, or</li> <li>from an integer type or unscoped enumeration type to an integer type that cannot represent all the values of the original type, except where the source is a constant expression and the actual value after conversion will fit into the target type and will produce the original value when converted back to the original type.</li> </ul> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload