[PATCH 1/5] libstdc++: Implement P2325 changes to default-constructibilty of views

Jonathan Wakely jwakely.gcc@gmail.com
Thu Jun 17 18:28:06 GMT 2021


On Thu, 17 Jun 2021, 19:19 Jonathan Wakely, <jwakely.gcc@gmail.com> wrote:

>
>
> On Thu, 17 Jun 2021, 16:50 Patrick Palka via Libstdc++, <
> libstdc++@gcc.gnu.org> wrote:
>
>> This implements the wording changes of P2325R3 "Views should not be
>> required to be default constructible".  Changes are relatively
>> straightforward, besides perhaps those to __box (which now stands
>> for copyable-box instead of semiregular-box) and __non_propagating_cache.
>>
>> For __box, this patch implements the recommended practice to also avoid
>> std::optional when the boxed type is nothrow_move/copy_constructible.
>>
>> For __non_propagating_cache, now that it's used by split_view::_M_current,
>> we need to add assignment from a value of the underlying type to the
>> subset of the std::optional API implemented for the cache (needed by
>> split_view::begin()).  Hence the new __non_propagating_cache::operator=
>> overload.
>>
>> While we're changing __box, this fixes the undesirable list-init in
>> the constuctors of the partial specialization as reported in PR100475
>> comment #7.
>
>
>
> As I said on IRC, I'm not sure why the defaulted default constructors need
> to be constrained (rather than just letting them get deleted) but the patch
> is OK.
>

Because the default member initializers are in the immediate context, so
the constructor would look valid to is_default_constructible, and only get
deleted when instantiated. (Thanks to Barry for reminding me of that.)

>


More information about the Gcc-patches mailing list