[Bug libstdc++/100940] views::take and views::drop should not define _S_has_simple_extra_args

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Jun 17 13:46:45 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100940

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:0f4a2fb44dad6c9c140226fc19ed16109b85e6f4

commit r12-1566-g0f4a2fb44dad6c9c140226fc19ed16109b85e6f4
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Jun 17 09:46:04 2021 -0400

    libstdc++: Refine range adaptors' "simple extra args" mechanism [PR100940]

    The _S_has_simple_extra_args mechanism is used to simplify forwarding
    of range adaptor's extra arguments when perfect forwarding call wrapper
    semantics isn't required for correctness, on a per-adaptor basis.
    Both views::take and views::drop are flagged as such, but it turns out
    perfect forwarding semantics are needed for these adaptors in some
    contrived cases, e.g. when their extra argument is a move-only class
    that's implicitly convertible to an integral type.

    To fix this, we could just clear the flag for views::take/drop as with
    views::split, but that'd come at the cost of acceptable diagnostics
    for ill-formed uses of these adaptors (see PR100577).

    This patch instead allows adaptors to parameterize their
    _S_has_simple_extra_args flag according the types of the captured extra
    arguments, so that we could conditionally disable perfect forwarding
    semantics only when the types of the extra arguments permit it.  We
    then use this finer-grained mechanism to safely disable perfect
    forwarding semantics for views::take/drop when the extra argument is
    integer-like, rather than incorrectly always disabling it.  Similarly,
    for views::split, rather than always enabling perfect forwarding
    semantics we now safely disable it when the extra argument is a scalar
    or a view, and recover good diagnostics for these common cases.

            PR libstdc++/100940

    libstdc++-v3/ChangeLog:

            * include/std/ranges (__adaptor::_RangeAdaptor): Document the
            template form of _S_has_simple_extra_args.
            (__adaptor::__adaptor_has_simple_extra_args): Add _Args template
            parameter pack.  Try to treat _S_has_simple_extra_args as a
            variable template parameterized by _Args.
            (__adaptor::_Partial): Pass _Arg/_Args to the constraint
            __adaptor_has_simple_extra_args.
            (views::_Take::_S_has_simple_extra_args): Templatize according
            to the type of the extra argument.
            (views::_Drop::_S_has_simple_extra_args): Likewise.
            (views::_Split::_S_has_simple_extra_args): Define.
            * testsuite/std/ranges/adaptors/100577.cc (test01, test02):
            Adjust after changes to _S_has_simple_extra_args mechanism.
            (test03): Define.


More information about the Gcc-bugs mailing list