This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] gdb: Use vector::emplace_back


On Wed, Nov 9, 2016 at 12:21 PM, Pedro Alves <palves@redhat.com> wrote:
>
> We just need names for the parameters that are obviously similar
> to the public members of the struct they'll be assigned to
> in the member initializer list just below.  (We use "m_" prefix for
> private members.  Public members of plain old data structs don't get
> the "m_" prefix.)
>
> Leading or trailing underscore are the most obvious choices, I think.

I know leading underscore is used in some projects, so I want to know
is it a C++ code standard that we use trailing underscore in this case or
it is your personal coding habit.  It is the latter.

>
> I mildly prefer trailing over leading for being less easily confused
> with "m_" IMO, and also, some coding conventions use single leading
> underscore for private member.  I see gcc using trailing underscore
> for "shadow" parameters too.  E.g.:
>
> id_base::id_base (id_kind kind_, const char *id_, int nargs_)
> {
>   kind = kind_;
>   id = id_;
>   nargs = nargs_;
>   hashval = htab_hash_string (id);
> }
>
> But it's probably possible to find different examples if you
> look deep enough.
>
> Would you do/prefer something different?
>

Since the trailing underscore usage like this is not mentioned in C++
code standard, people are free to use or not to use it.  I don't have
a preference on that.

-- 
Yao (齐尧)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]