From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>, Tom Tromey <tromey@adacore.com>
Subject: [PATCH] Use gdb::Requires in gdb::ref_ptr
Date: Thu, 21 May 2026 11:45:27 -0600 [thread overview]
Message-ID: <20260521174527.2962256-1-tromey@adacore.com> (raw)
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.
---
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
next reply other threads:[~2026-05-21 17:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 17:45 Tom Tromey [this message]
2026-05-29 16:04 ` Andrew Burgess
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=20260521174527.2962256-1-tromey@adacore.com \
--to=tromey@adacore.com \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.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