The C++17 standard says that the std::in_place
constructors of std::optional
must be explicit
(the same was with boost::optional
). But why?? What is the reason behind this?
It forbids to have a nice code like this:
struct Value
{
Value(int) { }
};
std::optional<Value> giveValueFive()
{
return {std::in_place, 5};
}