Subject: Re: [boost] Boost.Convert. Take 2.
From: Vladimir Batov (Vladimir.Batov_at_[hidden])
Date: 2014-02-20 17:48:18


On 02/21/2014 02:47 AM, Andrzej Krzemienski wrote:
>
> Regarding "Type Requirements" section in documentation:
> TypeOut needs to be
>
> *Copy Constructible.*
> Is it not enough to require that TypeOut be *MoveConstructible*?
>

I readily admit I am shaky about new C++11 stuff... even though it's
2014 outside... I've not had (cannot afford) any exposure to C++11 as I
am still stuck with C++03... well, at least for 2 more months... which
in the airline industry is more likely 6-12 months. :-(

Still I suspect some interfaces require to be Copy Constrictible. For
example,

template<typename TypeOut>
struct boost::convert<TypeOut>::result
{
     ...
     template<typename FallbackType>
     out_type value_or(FallbackType const& fallback) const
     {
         return good_ ? value_ : fallback;
     }
};

Above "out_type" is returned by-value as "fallback" might be of
FallbackType -- potentially other than (by convertible to) TypeOut type.
For example:

std::string res = convert<std::string>::from(25, cnv).value_or("C string");

However, I do not immediately see if we can have "value_" destroyed by
"move". So, Copy Constructible... I think.

I'd expect that to be the same in tr1::optional... unless you figured
out how to work around that issue... or I simply do not understand how
clever it can be. I'll happily accept your lead on this issue.

V.