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);


On Tue, 2004-06-15 at 13:10, Loren James Rittle wrote:
> 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.

Ok!


> 
> >> 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...

Neat trick!

Thanks :-)

-- 
        -Dhruv Matani.
http://www.geocities.com/dhruvbird/

Proud to be a Vegetarian.
http://www.vegetarianstarterkit.com/
http://www.vegkids.com/vegkids/index.html



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