From: "Metzger, Markus T" <markus.t.metzger@intel.com>
To: Andrew Burgess <aburgess@redhat.com>,
Simon Marchi <simon.marchi@polymtl.ca>
Cc: "vries@gcc.gnu.org" <vries@gcc.gnu.org>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [PATCH v3] gdb: c++ify btrace_target_info
Date: Mon, 11 Sep 2023 09:53:14 +0000 [thread overview]
Message-ID: <DM8PR11MB5749F19516990CA010191C3ADEF2A@DM8PR11MB5749.namprd11.prod.outlook.com> (raw)
In-Reply-To: <87r0n5kr1g.fsf@redhat.com>
Hello Andrew,
>>>> - gdb::unique_xmalloc_ptr<btrace_target_info> tinfo
>>>> - (XCNEW (btrace_target_info));
>>>> - tinfo->ptid = ptid;
>>>> + std::unique_ptr<linux_btrace_target_info> tinfo
>>>> + { new linux_btrace_target_info { ptid } };
>>>
>>>We recently added a gdb::make_unique function, it would make sense to
>>>you use it here (it will eventually become std::make_unique once we
>>>migrate to C++ 14).
>>>
>>>So this could be written as:
>>>
>>> auto tinfo = gdb::make_unique<linux_btrace_target_info> (ptid);
>>
>> I'm not a fan of 'auto'. So this becomes
>>
>> std::unique_ptr<linux_btrace_target_info> tinfo
>> { gdb::make_unique<linux_btrace_target_info> (ptid) };
>
>This really doesn't feel like an improvement.
>
>I also try to avoid excessive use of auto, so I dislike things like:
>
> auto var = some_function (....);
>
>because there's no hint what the type of var actually is (without
>looking at `some_function`). But in the case of:
>
> auto var = gdb::make_unique<type> (...);
>
>The type of var is right there on the line, so duplicating the type
>information is just noise. For me this is a perfect use of auto.
A related question is whether
auto ptr { gdb::make_unique<type> (...) }
is really any better than
std::unique_ptr<type> ptr { new type (...) }
regards,
markus.
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
next prev parent reply other threads:[~2023-09-11 9:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-08 10:53 Markus Metzger
2023-09-08 14:31 ` Simon Marchi
2023-09-11 6:18 ` Metzger, Markus T
2023-09-11 9:17 ` Andrew Burgess
2023-09-11 9:53 ` Metzger, Markus T [this message]
2023-09-11 14:25 ` Andrew Burgess
2023-09-11 15:27 ` Simon Marchi
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=DM8PR11MB5749F19516990CA010191C3ADEF2A@DM8PR11MB5749.namprd11.prod.outlook.com \
--to=markus.t.metzger@intel.com \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
--cc=vries@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).