Re: std::vector crash

From: Axel Naumann <Axel.Naumann_at_cern.ch>
Date: Fri, 17 Aug 2007 18:58:33 +0200


Hi Christian,

I didn't say it's forbidden. There are plenty of traces on discussions on that:

http://lists.boost.org/Archives/boost/2001/06/13554.php
http://www.thescripts.com/forum/thread171648.html
http://sourceware.org/autobook/autobook/autobook_48.html

to quote a few. So my recommendation stands :-)

Cheers, Axel.

Christian Holm Christensen wrote:
> Hi Axel,
>
> On Fri, 2007-08-17 at 12:43 +0200, Axel Naumann wrote:

>> Hi Ilya,

>
> ...
>
>> Totally independent remark:
>> type names should not start with an underscore in C(++). 

>
> Why not?! A valid identifier in C/C++ has the following form
>
> [_a-zA-Z][_a-zA-Z0-9]*
>
> That is, a letter or an underscore, follow by zero or more letters,
> numbers, or underscores. You can even use UTF encoded identifiers if
> you like - the standard, I believe, is quite explicit about that.
>
> In fact, GCC's libstdc++ uses underscores as the first character of data
> members. See for example "stdexcept":
>
> class logic_error : public exception
> {
> string _M_msg;
>
> There's absolutely _nothing_ wrong with using underscores as the first
> character of an identifier in C++. Personally, I prefer an underscore
> over ROOT's "f", but that's my preference, and I have the freedom to
> choose that convention.
>
> ROOT has, in my mind, some pretty weird conventions on this: For
> example, all classes (more or less) start with a `T' rather than live
> inside a `ROOT' name space, some class names are abbreviated beyond all
> recognition (TH1), and `modules' are differentiated by name rather than
> by structure (TGeo<XXX> should really be ROOT::Geometry::<XXX>, TG<YYY>
> should be ROOT::Gui::<YYY>).
>
> The point is, that there's all sorts of coding and naming conventions
> out there, and you are free to choose what ever you like, for better or
> for worse.
>
> BTW, using an underscore as the first character of a structure name is a
> _very_ common idiom in C. One then often finds a typedef from the
> structure name to the same name, but without the leading underscore:
>
> typedet struct _foo {
> ...
> } foo;
>
> That means you can write some stuff shorter, like
>
> void bar(foo* f);
>
> rather than
>
> void bar(struct _foo* f);
>
> However, as structures are just like classes (except members are public
> by default) in C++, and the `class' or `struct' prefix is not needed, it
> does not make much sense to use this idiom in C++. Doing
>
> struct foo { ... };
> void bar(foo* f);
>
> is perfectly legal C++ (but not legal C).
>
> Yours,
>
Received on Fri Aug 17 2007 - 18:58:39 CEST

This archive was generated by hypermail 2.2.0 : Fri Aug 17 2007 - 23:50:02 CEST