Boost logo

Boost :

From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2002-08-22 12:59:29


>From: "Terje Slettebø" <tslettebo_at_[hidden]>

Sorry, the last mail was sent too fast. Here's a correction:

> But in what way would this be useful for lexical_cast?
>
> if you have std::string as target, you have something like:
>
> std::stringstream interpreter;
>
> ...
>
> return std::string(interpreter.c_str());

This should be:

return std::string(interpreter.str());

This uses in fact a specialisation. Without specialisation for
std::basic_string as target, you'd have:

std::string str;

interpreter >> str;

return str;

The lexical_cast proposition doesn't use the specialisation above, maybe it
should? I can't say I see it as completely evident that calling str(),
followed by copy-construction, is faster than default-construction, followed
by operator>>().

Regards,

Terje


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk