From: Andrew Burgess <aburgess@redhat.com>
To: Tom Tromey <tromey@adacore.com>, gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: Re: [PATCH] Use gdb::Requires in gdb::ref_ptr
Date: Fri, 29 May 2026 17:04:50 +0100 [thread overview]
Message-ID: <87ldd2xkv1.fsf@redhat.com> (raw)
In-Reply-To: <20260521174527.2962256-1-tromey@adacore.com>
Tom Tromey <tromey@adacore.com> writes:
> Andrew pointed out that the use of is_convertible in gdb::ref_ptr is
> incorrect, and that it should instead check the value. This can
> easily be done using gdb::Requires.
Thanks for putting this patch together. LGTM.
Approved-By: Andrew Burgess <aburgess@redhat.com>
Thanks,
Andrew
> ---
> gdbsupport/gdb_ref_ptr.h | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/gdbsupport/gdb_ref_ptr.h b/gdbsupport/gdb_ref_ptr.h
> index 0eb654324c6..757c3f395ba 100644
> --- a/gdbsupport/gdb_ref_ptr.h
> +++ b/gdbsupport/gdb_ref_ptr.h
> @@ -21,6 +21,7 @@
> #define GDBSUPPORT_GDB_REF_PTR_H
>
> #include <cstddef>
> +#include "gdbsupport/traits.h"
>
> namespace gdb
> {
> @@ -76,7 +77,7 @@ class ref_ptr
>
> /* Copy another instance. */
> template<typename U,
> - typename = std::is_convertible<U *, T*>>
> + typename = gdb::Requires<std::is_convertible<U *, T*>>>
> ref_ptr (const ref_ptr<U, Policy> &other)
> : m_obj (other.m_obj)
> {
> @@ -93,7 +94,7 @@ class ref_ptr
>
> /* Transfer ownership from OTHER. */
> template<typename U,
> - typename = std::is_convertible<U *, T*>>
> + typename = gdb::Requires<std::is_convertible<U *, T*>>>
> ref_ptr (ref_ptr<U, Policy> &&other) noexcept
> : m_obj (other.m_obj)
> {
> @@ -115,7 +116,7 @@ class ref_ptr
>
> /* Copy another instance. */
> template<typename U,
> - typename = std::is_convertible<U *, T*>>
> + typename = gdb::Requires<std::is_convertible<U *, T*>>>
> ref_ptr &operator= (const ref_ptr<U, Policy> &other)
> {
> /* Note that self-assignment is not checked here, as it isn't
> @@ -141,7 +142,7 @@ class ref_ptr
>
> /* Transfer ownership from OTHER. */
> template<typename U,
> - typename = std::is_convertible<U *, T*>>
> + typename = gdb::Requires<std::is_convertible<U *, T*>>>
> ref_ptr &operator= (ref_ptr<U, Policy> &&other)
> {
> /* Note that self-assignment is not checked here, as it isn't
>
> base-commit: ea27a7ae9048367bde15246b248f856803efc674
> --
> 2.54.0
prev parent reply other threads:[~2026-05-29 16:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 17:45 Tom Tromey
2026-05-29 16:04 ` Andrew Burgess [this message]
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=87ldd2xkv1.fsf@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@adacore.com \
/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