Consider the following example where we parse data and pass the result to the next function:
Content Parse(const std::string& data);
void Process(Content content);
int main()
{
auto data = ReadData();
Process(Parse(data));
}
Now let's change the code using std::optional
to handle a failed parsing step:
optional<Content> Parse(const std::string& data);
void Process(Content content);
int main()
{
auto data = ReadData();
auto content = Parse(data);
if (content)
Process(move(*content));
}
Is it valid to move from optional<T>::value()
? If it's ok for std::optional
is it valid for boost::optional
as well?