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

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tomasz Kaminski <tkami...@gcc.gnu.org>:

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

commit r16-618-g0e93f7cd4ed0cf6bcfda90ed4dcad51a1f65b4b6
Author: Tomasz KamiÅski <tkami...@redhat.com>
Date:   Mon May 12 10:01:22 2025 +0200

    libstdc++: Implement C++26 copyable_function [PR119125]

    This patch implements C++26 copyable_function as specified in P2548R6.
    It also implements LWG 4255 that adjust move_only_function so constructing
    from empty copyable_function, produces empty functor. This falls from
    existing checks, after specializing __is_polymorphic_function_v for
    copyable_function specializations.

    For compatible invoker signatures, the move_only_function may be
constructed
    from copyable_funciton without double indirection. To achieve that we
derive
    _Cpy_base from _Mo_base, and specialize __is_polymorphic_function_v for
    copyable_function. Similary copyable_functions with compatible signatures
    can be converted without double indirection.

    As we starting to use _Op::_Copy operation from the _M_manage function,
    invocations of that functions may now throw exceptions, so noexcept needs
    to be removed from the signature of stored _M_manage pointers. This also
    affects operations in _Mo_base, however we already wrap _M_manage
invocations
    in noexcept member functions (_M_move, _M_destroy, swap).

            PR libstdc++/119125

    libstdc++-v3/ChangeLog:

            * doc/doxygen/stdheader.cc: Addded cpyfunc_impl.h header.
            * include/Makefile.am: Add bits cpyfunc_impl.h.
            * include/Makefile.in: Add bits cpyfunc_impl.h.
            * include/bits/cpyfunc_impl.h: New file.
            * include/bits/mofunc_impl.h: Mention LWG 4255.
            * include/bits/move_only_function.h: Update header description
            and change guard to also check __glibcxx_copyable_function.
            (_Manager::_Func): Remove noexcept.
            (std::__is_polymorphic_function_v<move_only_function<_Tp>>)
           
(__variant::_Never_valueless_alt<std::move_only_function<_Signature...>>)
            (move_only_function) [__glibcxx_move_only_function]: Adjust guard.
            (std::__is_polymorphic_function_v<copyable_function<_Tp>>)
           
(__variant::_Never_valueless_alt<std::copyable_function<_Signature...>>)
            (__polyfunc::_Cpy_base, std::copyable_function)
            [__glibcxx_copyable_function]: Define.
            * include/bits/version.def: Define copyable_function.
            * include/bits/version.h: Regenerate.
            * include/std/functional: Define __cpp_lib_copyable_function.
            * src/c++23/std.cc.in (copyable_function)
            [__cpp_lib_copyable_function]: Export.
            * testsuite/20_util/copyable_function/call.cc: New test based on
            move_only_function tests.
            * testsuite/20_util/copyable_function/cons.cc: New test based on
            move_only_function tests.
            * testsuite/20_util/copyable_function/conv.cc: New test based on
            move_only_function tests.
            * testsuite/20_util/copyable_function/copy.cc: New test.
            * testsuite/20_util/copyable_function/move.cc: New test based on
            move_only_function tests.

    Reviewed-by: Jonathan Wakely <jwak...@redhat.com>
    Signed-off-by: Tomasz KamiÅski <tkami...@redhat.com>

Reply via email to