Namespaces
Variants
Views
Actions

Difference between revisions of "Talk:cpp/utility/optional/and then"

From cppreference.com
(Why restricted return type?)
 
(Never mind)
Line 2: Line 2:
 
It would be far more convenient if the method itself constructed the optional and more in keeping with convenient syntax in other languages such as C#: a?.foo()?.bar()?.baz().
 
It would be far more convenient if the method itself constructed the optional and more in keeping with convenient syntax in other languages such as C#: a?.foo()?.bar()?.baz().
 
It also requires a default constructible result type, which is another needles(?) restriction.
 
It also requires a default constructible result type, which is another needles(?) restriction.
 +
 +
Never mind  - The method I was expecting is called "transform".

Revision as of 01:03, 9 November 2021

Why do these methods require that the return type is drived from std::optional? It would be far more convenient if the method itself constructed the optional and more in keeping with convenient syntax in other languages such as C#: a?.foo()?.bar()?.baz(). It also requires a default constructible result type, which is another needles(?) restriction.

Never mind - The method I was expecting is called "transform".