Boost logo

Boost :

Subject: Re: [boost] Variadic append for std::string
From: Hans Dembinski (hans.dembinski_at_[hidden])
Date: 2017-01-26 04:41:23


>> 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(…));

But both should be supported.


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