public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/111667] [C++23] Implement P1132R8, out_ptr - a scalable output pointer abstraction
Date: Thu, 16 Nov 2023 08:12:40 +0000	[thread overview]
Message-ID: <bug-111667-4-WwS2nWGRnZ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111667-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:c7f6537db94f7c6320a5a8ecaa387c9b9ce1f0ac

commit r14-5524-gc7f6537db94f7c6320a5a8ecaa387c9b9ce1f0ac
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Nov 15 23:02:34 2023 +0000

    libstdc++: Implement std::out_ptr and std::inout_ptr for C++23 [PR111667]

    This implements that changes from P1132R8, including optimized paths for
    std::shared_ptr and std::unique_ptr.

    For std::shared_ptr we pre-allocate a new control block in the
    std::out_ptr_t constructor so that the destructor is non-throwing. This
    requires some care because unlike the shared_ptr(Y*, D, A) constructor,
    we don't want to invoke the deleter if allocating the control block
    throws, because we don't own any pointer yet. In order to avoid the
    unwanted deleter invocation, we create the control block manually. We
    also want to avoid invoking the deleter on a null pointer on
    destruction, so we destroy the control block manually if there is no
    pointer to take ownership of.

    For std::unique_ptr and for raw pointers, the out_ptr_t object hands out
    direct access to the pointer, so that we don't have anything to do
    (except possibly assign a new deleter) in the ~out_ptr_t destructor.

    These optimizations avoid requiring additional temporary storage for the
    pointer (and optional arguments), and avoid additional instructions to
    copy that pointer into the smart pointer at the end.

    libstdc++-v3/ChangeLog:

            PR libstdc++/111667
            * include/Makefile.am: Add new header.
            * include/Makefile.in: Regenerate.
            * include/bits/out_ptr.h: New file.
            * include/bits/shared_ptr.h (__is_shared_ptr): Move definition
            to here ...
            * include/bits/shared_ptr_atomic.h (__is_shared_ptr): ... from
            here.
            * include/bits/shared_ptr_base.h (__shared_count): Declare
            out_ptr_t as a friend.
            (_Sp_counted_deleter, __shared_ptr): Likewise.
            * include/bits/unique_ptr.h (unique_ptr, unique_ptr<T[], D>):
            Declare out_ptr_t and inout_ptr_t as friends.
            (__is_unique_ptr): Define new variable template.
            * include/bits/version.def (out_ptr): Define.
            * include/bits/version.h: Regenerate.
            * include/std/memory: Include new header.
            * testsuite/20_util/smartptr.adapt/inout_ptr/1.cc: New test.
            * testsuite/20_util/smartptr.adapt/inout_ptr/2.cc: New test.
            * testsuite/20_util/smartptr.adapt/inout_ptr/shared_ptr_neg.cc:
            New test.
            * testsuite/20_util/smartptr.adapt/inout_ptr/void_ptr.cc: New
            test.
            * testsuite/20_util/smartptr.adapt/out_ptr/1.cc: New test.
            * testsuite/20_util/smartptr.adapt/out_ptr/2.cc: New test.
            * testsuite/20_util/smartptr.adapt/out_ptr/shared_ptr_neg.cc:
            New test.
            * testsuite/20_util/smartptr.adapt/out_ptr/void_ptr.cc: New
            test.

  parent reply	other threads:[~2023-11-16  8:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-02 18:18 [Bug libstdc++/111667] New: " redi at gcc dot gnu.org
2023-10-02 18:24 ` [Bug libstdc++/111667] " pinskia at gcc dot gnu.org
2023-10-02 18:24 ` pinskia at gcc dot gnu.org
2023-11-09 15:55 ` redi at gcc dot gnu.org
2023-11-16  8:12 ` cvs-commit at gcc dot gnu.org [this message]
2023-11-16  8:14 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-111667-4-WwS2nWGRnZ@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).