Why I love C++ so much.

Dave Korn dave.korn@artimi.com
Thu Feb 21 10:10:00 GMT 2008


On 21 February 2008 01:18, Gary R. Van Sickle wrote:

>> From: Dave Korn
>> 
>> 
>>   Because writing
>> 
>>   hex << setw (8) << setfill ('0') << ((uintptr_t)(x)) << dec << setfill
>> (' ') 
>> 
>> is just soooooo much easier and more self-consistent and less typing than
>> 
>>   "%08x", x
>> 
>> 
>> 
>> <grrrspit>
>> 
> 
> Ummm... Kornsy?  All the *printf()'s are available for your use in every
> standard C++ library I've ever come across, if you really want to risk the
> security and portability problems.

  Which makes the above monstrosity an even worse waste of time, space and
energy!  I mean look at that shabby mess!  Modal operators!
Non-modal-self-resetting operators!  Inferring the field type from the width
of the integer!

  That's /why/ I end up using those *printfs in C++ all the time.

> Or are you telling us that you have a C compiler that magically compiles the
> bare symbols:
> 
> 	"%08x", x
> 
> into some sort of string and/or output?  That might be cool, but I think
> that's Perl ;-).

  LOFL.  Nah, I was just comparing the equivalent subsequences from debugging
print statements.

  Of course, if you know of a C++ compiler that lets you print into the 'hex'
operator, maybe I know of a C compiler that can infer you mean a printf from a
comma-expression...

  And this is where we came in.  Because /the C++ way/ would be to say "I
know, let's create an overloaded "const char *operator, (int &x)", that treats
the first operand as a format string and the second as a varargs list.  Or
maybe they'd invent templates or something really far-out and bizarre instead.
I dunno, they're mad, all mad I tell you, pronounced
"MAaaaaa-hahuahauaahuaaa-aaad!" and spelt "gibberboinkwibble".

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....



More information about the Cygwin-talk mailing list