Skip to content
This repository was archived by the owner on Jun 3, 2018. It is now read-only.
This repository was archived by the owner on Jun 3, 2018. It is now read-only.

operator== Missing for void specialization  #29

@shua27

Description

@shua27

When attempting to compare expected objects specialized with a void value type, I get the following error during compilation:

error: no match foroperator*’ (operand type is ‘const nonstd::expected<void, CUSTOM_ERROR_CODE>’) 
        return bool(x) != bool(y) ? false : bool(x) == false ? true : *x == *y;

Obviously this wouldn't compile as you can't compare as the void specialization of expected doesn't (can't) have an implementation of operator*.

Currently, the behavior of the operator== when T is not void is such that the values are compared if a value exists, else just the truthiness is compared, which makes sense. Reference.

Extending this logic to the void specialization would just require comparing the truthiness of the object, as all void expected objects should be equal:

template <typename E>
constexpr bool operator==( expected<void,E> const & x, expected<void,E> const & y )
{
    return bool(x) == bool(y);
}

Is there a reason why the equality operator hasn't been implemented for the void specialization?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions