
12 Feb
2009
12 Feb
'09
4:23 p.m.
David Abrahams wrote:
on Wed Feb 11 2009, Andrey Semashev <andrey.semashev-AT-gmail.com> wrote:
Vladimir.Batov@wrsa.com.au wrote:
int i; std::string s;
1) int i_from_s = boost::string::to<int>(s); // throws bs::to_string?
The above is converting a string to an int, so to_string would be inappropriate. I.e. string::to and to_string are grammatically different.
2) std::string s_from_i = boost::string::from<int>(i); bs::from_string?
Ditto.
Oh, I certainly meant in reverse.
Everything looks fine with me, except that I would suggest using a more explicit syntax for the default value specification. Like this:
boost::string::to<int>(s).with_default(-1);
boost::string::to<int>(s, _default=-1)
?
see Boost.Parameter
Yes, that's a good alternative.