News for hackers. Stuff that matters.
Re:Functional exceptionless error-handling with optional and... by HumanDrivenDev on Sunday December 03, 2017 @01:51PM (#15838853)
It's not a great usecase for optionals. a better one would be retrieving a value from a std::map - that one is pretty binary, it's either there or it isn't.

To me optionals are for things where you'd consider it reasonable to return a null that represents "doesn't exist".

Re:Functional exceptionless error-handling with optional and... by Shoothe on Sunday December 03, 2017 @02:31PM (#15839045)
But if you already have null then the method could return null, empty optional or optional with value.
Re:Functional exceptionless error-handling with optional and... by HumanDrivenDev on Sunday December 03, 2017 @03:53PM (#15839527)
I don't know about C++, but for example Java has a method "ofNullable" that will convert a null to a None option.

But yes, that could potentially happen. IIRC that problem exists in many languages, including F# and Scala. Not sure how big of an issue it is in practice...