|
Boost : |
Subject: Re: [boost] Variadic append for std::string
From: Olaf van der Spek (ml_at_[hidden])
Date: 2017-01-26 04:55:18
On Thu, Jan 26, 2017 at 10:41 AM, Hans Dembinski <hans.dembinski_at_[hidden]>
wrote:
>
> >> Note that I am still resisting the idea of .str() as a member function.
> If
> >> the joiner or concatenation object exports begin() and end(), it's
> >> un-necessary, because the object returned by create_string() (or
> similar)
> >> can use the iterators.
> >
> > I like that idea, though I still don't like the name to_string().
> >
> > How about this:
> >
> > auto s = generate<std::sting>(concat(...));
> > auto ws = generate<std::wsting>(concat(...));
>
> Why don't you add explicit conversion operators to the string factory
>
> explicit operator std::string() { ⦠}
> explicit operator std::wstring() { ⦠}
>
> explicit type conversion was exactly added for this situation in C++11.
> The call is then
>
> auto s = static_cast<std::string>(concat(â¦));
>
> etc.
>
> Otherwise I don't care if you add .str() or .to_string() members. I would
> prefer writing
>
> auto s = concat(â¦).str();
>
>
> over
>
> auto s = static_cast<std::string>(concat(â¦));
>
auto s = std::string(concat(â¦));
Or even
std::string s(concat(â¦));
?
Why bother with the static_cast?
-- Olaf
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk