[lug] [OT] C++ trick?

D. Stimits stimits at attbi.com
Thu Jan 23 23:36:00 MST 2003


Scott Herod wrote:

> Hello,
>
> I'm looking for C++ trick (mainly because it's pretty late, and I'm
> getting tired of sending someone notes that the function he's using is
> not in a standard header file).
>
> I want to create a macro to replace "itoa( i, buf, size )" basically with
> a function like:
>
> string f ( int i ) {
>   stringstream b;
>   b << i << ends;
>   return b.str();
> }
>
>
> The following doesn't work because the operator<<() creates ostreams which
> don't know about the str() function of stringstreams.
>
> #define itoa(i,buf,val) \
> (stringstream().operator<<(i).operator<<(ends)).str()
>
>
> Can someone suggest a trick?  I'm going to send the culprit a note asking
> him to include my #define immediately after there #include .
>
> Thanks
>
> Scott
>
>
I can't actually answer, I'm ready to go to sleep myself. Just wondering 
if you have some form of spam filter removing attbi dot com? I'd sent 
you a couple of emails, they seem to have disappeared into /dev/null.

D. Stimits, stimits AT attbi DOT com




More information about the LUG mailing list