26 May
2017
26 May
'17
2:23 p.m.
Niall Douglas wrote:
But after I built up some experience, now I tend to write this instead:
result<Foo> something() { result<Foo> ret(Foo()); Foo &foo = ret.value(); ... build foo ... return ret; }
This takes us back to "what if due to a logic error the code that should build `foo` doesn't?" And since you've constructed `ret` to non-empty, the point of empty is, again, lost.