[patch] One last ErrorOr simplification

David Blaikie dblaikie at gmail.com
Tue Nov 5 09:36:40 PST 2013


On Tue, Nov 5, 2013 at 9:04 AM, Rafael EspĂ­ndola <rafael.espindola at gmail.com
> wrote:

> The attached patch removes another unused, and IMHO, not very
> desirable feature of ErrorOr.
>
> One of the uses of the IsValid flag is to support default constructing
> a ErrorOr that is not a Error or a Value. There is not much value in
> doing that IMHO. If ErrorOr was to have a default constructor, it
> should be implemented by default constructing the value, but even that
> looks unnecessary.
>
> The other use is to avoid calling destructors on moved objects. This
> looks wrong. If the data being moved has non trivial treatment of
> moves (an std::vector for example), it is its destructor that should
> handle it, not ~ErrorOr.
>

I sort of like this functionality, but I agree with your logic that it's
not strictly the purview of this type to handle this case (I'm still on the
fence). In any case it looks like this functionality was
misimplemented/broken anyway - the moved-from data object never gets its
dtor run by the ErrorOr move ctor...


>
> With this change ErrorOr becomes a fairly simple wrapper and should
> always be better than using an error_code + value in an API.
>
> Cheers,
> Rafael
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131105/bcbfc8ab/attachment.html>


More information about the llvm-commits mailing list