This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C++ coding style inconsistencies
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>, Richard Sandiford <rdsandiford at googlemail dot com>
- Date: Thu, 25 Jun 2015 20:07:15 +0100
- Subject: Re: C++ coding style inconsistencies
- Authentication-results: sourceware.org; auth=none
- References: <87vbeblk0y dot fsf at googlemail dot com>
On 25 June 2015 at 19:28, Richard Sandiford wrote:
> (2) Is there supposed to be a space before a template parameter list?
> I.e. is it:
>
> foo<bar>
>
> or:
>
> foo <bar>
>
> ? Both are widely used.
>
> The current coding conventions don't say explicitly, but all the
> examples use the second style. It's also more in keeping with
> convention for function parameters. On the other hand, it could
> be argued that the space in:
>
> foo <bar, frob>::thing
>
> makes the binding confusing and looks silly compared to:
>
> foo<bar, frob>::thing
>
> But there again, the second one might look like two unrelated
> blobs at first glance.
I think the extra space makes no sense here, and I've not seen it used
in idiomatic C++.
The name of the type is "foo<bar, frob>", it's not a function call.
If the point is just to break things up with whitespace (which does
seem to be the motivation for the space before function parameters in
the GNU style) then
foo<bar, frob> :: thing
might make more sense (and some people do use that style but I don't
like it personally).