This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++23 status.

3629. make_error_code and make_error_condition are customization points

Section: 19.5 [syserr] Status: C++23 Submitter: Jonathan Wakely Opened: 2021-10-31 Last modified: 2023-11-22

Priority: 2

View all other issues in [syserr].

View all issues with C++23 status.

Discussion:

The rule in 16.4.2.2 [contents] means that the calls to make_error_code in 19.5.4.2 [syserr.errcode.constructors] and 19.5.4.3 [syserr.errcode.modifiers] are required to call std::make_error_code, which means program-defined error codes do not work. The same applies to the make_error_condition calls in 19.5.5.2 [syserr.errcondition.constructors] and 19.5.5.3 [syserr.errcondition.modifiers].

They need to use ADL. This is what all known implementations (including Boost.System) do.

[2022-01-29; Reflector poll]

Set priority to 2 after reflector poll.

Previous resolution [SUPERSEDED]:

This wording is relative to N4901.

  1. Modify 19.5.2 [system.error.syn] as indicated:

    -1- The value of each enum errc constant shall be the same as the value of the <cerrno> macro shown in the above synopsis. Whether or not the <system_error> implementation exposes the <cerrno> macros is unspecified.

    -?- Invocations of make_error_code and make_error_condition shown in subclause 19.5 [syserr] select a function to call via overload resolution (12.2 [over.match]) on a candidate set that includes the lookup set found by argument dependent lookup (6.5.4 [basic.lookup.argdep]).

    -2- The is_error_code_enum and is_error_condition_enum templates may be specialized for program-defined types to indicate that such types are eligible for class error_code and class error_condition implicit conversions, respectively.

    [Note 1: Conversions from such types are done by program-defined overloads of make_error_code and make_error_condition, found by ADL. —end note]

[2022-08-25; Jonathan Wakely provides improved wording]

Discussed in LWG telecon and decided on new direction:

[2022-09-07; Jonathan Wakely revises wording]

Discussed in LWG telecon. Decided to change "established as-if by performing unqualified name lookup and argument-dependent lookup" to simply "established as-if by performing argument-dependent lookup".

This resolves the question of whether std::make_error_code(errc), std::make_error_code(io_errc), etc. should be visible to the unqualified name lookup. This affects whether a program-defined type that specializes is_error_code_enum but doesn't provide an overload of make_error_code should find the overloads in namespace std and consider them for overload resolution, via implicit conversion to std::errc, std::io_errc, etc.

[2022-09-23; Reflector poll]

Set status to Tentatively Ready after seven votes in favour during reflector poll.

[2022-11-12 Approved at November 2022 meeting in Kona. Status changed: Voting → WP.]

Proposed resolution:

This wording is relative to N4910.