public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: David Malcolm <dmalcolm@redhat.com>
Cc: gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] C++: simplify output from suggest_alternatives_for
Date: Tue, 09 Oct 2018 23:29:00 -0000	[thread overview]
Message-ID: <CADzB+2kUV+gZA7h_MqMcM=QNiiBEEm-BgOrTfdCBcM_FeCG7rw@mail.gmail.com> (raw)
In-Reply-To: <1539108435-4967-1-git-send-email-dmalcolm@redhat.com>

On Tue, Oct 9, 2018 at 1:19 PM David Malcolm <dmalcolm@redhat.com> wrote:
> +  /* Emulation of a "move" constructor, but really a copy
> +     constructor.  */
> +
> +  name_hint (const name_hint &other)
> +  : m_suggestion (other.m_suggestion),
> +    m_deferred (const_cast<name_hint &> (other).take_deferred ())
> +  {
> +  }
> +
> +  /* Emulation of "move" assigment, but really copy assignment.  */
> +
> +  name_hint& operator= (const name_hint &other)
> +  {
> +    m_suggestion = other.m_suggestion;
> +    m_deferred = const_cast<name_hint &> (other).take_deferred ();
> +    return *this;
> +  }
> +
> +  /* Take ownership of this name_hint's deferred_diagnostic, for use
> +     in chaining up deferred diagnostics.  */
> +  gnu::unique_ptr<deferred_diagnostic> take_deferred () { return move (m_deferred); }

Why do you want to propagate this hackery into name_hint?  I would
expect the defaulted special member functions to do the right thing
with m_deferred: in -std=c++98 the implicit copy ops call the
gnu::unique_ptr copy ops that actually move, and in -std=c++11 and up
we're calling the move constructor for std::unique_ptr, which does the
right thing.

This also doesn't limit the hack to C++98 mode the way unique-ptr.h does.

Jason

  reply	other threads:[~2018-10-09 22:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-09 19:08 David Malcolm
2018-10-09 23:29 ` Jason Merrill [this message]
2018-10-10 21:18   ` [PATCH] v2: " David Malcolm
2018-10-11 14:39     ` Jason Merrill
2018-10-11 14:39       ` Jason Merrill
2018-10-12  0:25         ` [PATCH] v3: " David Malcolm
2018-10-25 19:07           ` Jason Merrill
2018-10-10 15:35 ` [PATCH] " Jason Merrill

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='CADzB+2kUV+gZA7h_MqMcM=QNiiBEEm-BgOrTfdCBcM_FeCG7rw@mail.gmail.com' \
    --to=jason@redhat.com \
    --cc=dmalcolm@redhat.com \
    --cc=gcc-patches@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).