"Greg London" <[email protected]> writes:

> Cool!  15 years of perl and I never used /e
>
> I got the regexp to convert the first file
> and discovered that sprintf is way more inconvenient
> than I remember. It doesn't return the string,
> it returns pass/fail. And it operates on char* ?
>
> This may have been why I used boost::format.
>
> Anyone know of a c++ self contained function that takes
> a format string and returns the result string
> rather than using char*'s and returning the value in
> a char*?

The boost::format documentation and the following stack overflow thread
refer to a library by James Kanze and John Dibling that pre-dates
Boost::Format, but I can't find it with a quick look. Kanze is not
enthusiastic about it in his comment, so perhaps he retracted it, but
maybe you can track it down:

http://stackoverflow.com/questions/16696165/any-library-that-does-printf-on-a-c-stream

Aside from the above problem with sprintf, I'd be worried about type
errors. e.g. boost::format's %s I'm guessing could take a corresponding
std::string arg as is, but if you convert that directly you'll blow away
your stack, sprintf expecting a char* not a std::string when it sees
%s. You could make sure to put .c_str() after, but what other implicit
type conversions might be lurking that won't be done by sprintf?

What about converting to std::ostringstream instead?

-- 
Mike Small
[email protected]

_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to