This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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: [RFC] std::string(0);


In article <1087279330.1403.0.camel@localhost.localdomain>,
Dhruv Matani<dhruvbird@gmx.net> writes:

>>> BTW, would "" be equivalent to '\0'?

"" is a pointer.  '\0' is a character.

>> No, but ""[0] is equivalent to '\0'...

"Most" pointers may be dereferenced with [] thus ""[0] is a
dereferenced pointer (which happens to be '\0' by language definition ;-).

> I'm sorry, but what is: ""[0]?

If it is still not clear, maybe this context will help:

int printable_nibble (int i) { return "0123456789abcdef"[i % 16]; }

You will actually find this idiom/hack in real, production C code...

Regards,
Loren


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