Skip to content

error cannot be compared with == and cannot be built from std::errc #37

Description

@skipbit

Two things a caller would expect from dross::error are not available.

No operator== between two errors

include/dross/type/error.h declares a hand-written operator<=>(const error&). Under C++20 rules a user-declared three-way comparison synthesises the relational operators but not operator==, and none is declared, so a == b does not compile for two error values. The equality operators that do exist take an enum or a category, not another error.

The test added for the type works around this by comparing through <=> instead.

std::errc is rejected

The error_enum_type concept requires std::is_error_code_enum_v<E>. std::errc is an error condition enum: is_error_condition_enum_v<std::errc> is true and is_error_code_enum_v<std::errc> is false. So the templated constructor does not accept std::errc, which is the enumeration a caller reaches for first.

std::io_errc works, because it is an error code enum, but it covers one narrow domain.

Note

Accepting std::errc means either widening the concept to admit condition enums (and deciding what code() should then return) or providing a separate constructor. Both change the contract, so this needs a decision rather than a patch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions