|
Boost : |
Subject: Re: [boost] Formal Review Request: Boost.String.Convert
From: Christian Holmquist (c.holmquist_at_[hidden])
Date: 2009-02-18 11:40:12
2009/2/18 Stewart, Robert <Robert.Stewart_at_[hidden]>
> On Wednesday, February 18, 2009 10:11 AM
> Scott McMurray wrote:
> > >
> > I'm just not convinced that convert(-1) tells me that I should be
> > getting a std::string. I think it's equally (if not more) plausible
> > that it should be some internationalizable string, be it std::wstring,
> > std::u8string, or what.
>
> It doesn't. I contend that should be convert(s, -1), where s is a
> std::string, or convert<std::string>(-1). Other, more verbose spellings are
> possible, of course.
>
> Isn't it so that
string to_string(T const&, Format) is about string generation, such as
Spirit::Karma
and
boost::optional<T> from_string<T>(String) is about parsing, such as
Spirit::Qi.
and
StringT convert_string<StringT>(String)
about character conversion.
The name 'convert' doesn't tell me anything about strings, for all I know
the following could be valid:
convert<std::vector<int> >(std::list<float> >()) ;
boost::to_string/boost::from_string would be very useful if made right, but
seems this discussion is mostly about nifty expressions such as
convert("5").to<int>(), which is close to unusable to me.
How would the following trivial case be written?
vector<int> v;
std::vector<std::string> s;
std::transform(v.begin(), v.end(), boost::bind(convert, _1, ????),
std::back_inserter(s));
I've not seen much discussions on how to provide formatters, or how to
extend with user-defined types. Isn't that important for such a library?
/ Christian
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk