Date: Thu, 06 Aug 2020 17:30:57 +0200

I think it is supposed to be a narrowing conversion, but the draft says

this in the definition of a narrowing conversion:

| 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 whose value after integral

| promotions will fit into the target type,

<http://eel.is/c++draft/dcl.init.list#7.4>

With <http://eel.is/c++draft/conv.bool> 2 fits into the bool type. I

don't think there is another meaningful way to get an int into a bool.

It's not a value-preserving conversation, of course, but that's only

part of the narrowing conversion definition for floating point types.

Would it be possible to use more precise language than “represent all

the values“ and “fit into the target type” here?

Thanks,

Florian

this in the definition of a narrowing conversion:

| 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 whose value after integral

| promotions will fit into the target type,

<http://eel.is/c++draft/dcl.init.list#7.4>

With <http://eel.is/c++draft/conv.bool> 2 fits into the bool type. I

don't think there is another meaningful way to get an int into a bool.

It's not a value-preserving conversation, of course, but that's only

part of the narrowing conversion definition for floating point types.

Would it be possible to use more precise language than “represent all

the values“ and “fit into the target type” here?

Thanks,

Florian

Received on 2020-08-06 10:34:27