|
Boost : |
From: Pavel Vozenilek (pavel_vozenilek_at_[hidden])
Date: 2003-06-04 23:12:50
lexical_cast<> constructs and destroys std::stringstream
(including dynamic memory allocation/free.)
each time a conversion is done.
Maybe specialised version of lexical_cast<> can be developed
which takes external, existing stringstream instance as
template parameter and reuses it.
Very rough idea:
template<typename Target, std::stringstream& ss, typename Source>
Target lex_cast(Source s)
{
// clear ss
ss << s;
Target t;
ss >> t;
return t;
}
extern std::stringstream ss;
std::stringstream ss;
...
int a = 99;
std::string s = lex_cast<std::string, ss>(a);
/Pavel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk