Boost logo

Boost :

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


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

> >From: "Early Ehlinger" <earlye_at_[hidden]>
>
> > std::stringstream temp;
> > temp << source;
> > return TargetType( temp.str().c_str() );
> >
> This exact solution would work as long as the other string-types
implements
> the c_str() member function, like std::string.

Oops, I misread the code. This would work for any target type that has a
constructor which accepts a (const) char *. This is a good suggestion, and
it's kind of an extension to Gennadiy's proposal
(http://groups.yahoo.com/group/boost/files/lexical_cast_propositions/proposi
tion1.cpp), which constructs the stringstream directly from a string, if the
_source_ is a string. Your proposal covers if the _target_ is a string. I
was going to add Gennadiy's proposal, and I'll add yours, as well. Thanks
for the suggestion.

Regards,

Terje


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