Boost logo

Boost :

Subject: Re: [boost] [outcome] expected, etc. why are these assignable
From: Peter Dimov (lists_at_[hidden])
Date: 2017-06-02 16:43:35


Richard Hodges wrote:
> Forgive me chiming in late, but what is the semantic difference between:
>
> enum class no_difference
> {
> _
> }
>
> expected<std::path, no_difference, std::error_code, std::exception_ptr>
>
> and this:
>
> using path_difference = std::variant<std::path, no_difference>;
> using error = std::variant<std::error_code, std::exception_ptr>;
>
> expected<path_difference, error> return_first_diff(...);

There are various ways to represent the same four-state variant
syntactically, and the main difference is in, well, syntax, when referring
to it. You could, for example, use

    outcome<variant<std::path, no_difference>>

(assuming a never-empty tri-state outcome)

or

    outcome<optional<std::path>>

At some point for a detailed comparison one would need to take a
representative example and write down the user code under each alternative.

You're right that in this case both "std::path" and "no_difference" seem
more like values, although I don't remember how it was in Niall's original
AFIO example.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk