On 9/28/23 05:55, Richard Sandiford wrote:
poly_int was written before the switch to C++11 and so couldn't
use explicit default constructors.  This led to an awkward split
between poly_int_pod and poly_int.  poly_int simply inherited from
poly_int_pod and added constructors, with the argumentless constructor
having an empty body.  But inheritance meant that poly_int had to
repeat the assignment operators from poly_int_pod (again, no C++11,
so no "using" to inherit base-class implementations).

All that goes away if we switch to using default constructors.

The main complication is ensuring that braced initialisation still
gives a constexpr, so that static variables can be initialised without
runtime code.  The two problems here are:

(1) When initialising a poly_int<N, wide_int> with fewer than N
     coefficients, the other coefficients need to be a zero of
     the same precision as the explicit coefficients.  This was
     previously done in a for loop using wi::ints_for<...>::zero,
     but C++11 constexpr constructors can't have function bodies.
     The patch instead uses a series of delegated initialisers to
     fill in the implicit coefficients.

Perhaps it's time to update the bootstrap requirement to C++14 (i.e. GCC 5, from eight years ago). Not that this would affect this particular patch.

Jason

Reply via email to