Mike Stump <mikest...@comcast.net> writes:
>>> * A static assert also prevents fixed_wide_ints from being initialised
>>>   from wide_ints.  I think combinations like that would always be a
>>>   mistake.
>
> I don't see why.  In C, this:
>
>   int i;
>   long l = i;
>
> is not an error, and while a user might not want to do this, other
> times, it is completely reasonable.

Sure, but in these terms, "int" is FLEXIBLE_PRECISION, while wide_int
is VAR_PRECISION.  You can do the above because "int" has a sign,
and so the compiler knows how to extend it to wider types.  wide_int
doesn't have a sign, so if you want to extend it to wider types you
need to specify a sign explicitly.  So you can do:

   max_wide_int x = max_wide_int::from (wide_int_var, SIGNED);
   max_wide_int x = max_wide_int::from (wide_int_var, UNSIGNED);

What I'm saying is that the assert stops plain:

   max_wide_int x = wide_int_var;

since it's very unlikely that you'd know up-front that wide_int_var
has precision MAX_BITSIZE_MODE_ANY_INT.

FLEXIBLE_PRECISION is for integers that act in a C-like way.
CONST_PRECISION and VAR_PRECISION are (deliberately) not C-like.

Thanks,
Richard

Reply via email to