make_error_code and make_error_condition are customization points
Jonathan Wakely

Created on 2021-10-31.00:00:00 last changed 3 weeks ago


Date: 2021-10-31.18:56:02

Proposed resolution:

This wording is relative to N4901.

  1. Modify [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 [syserr] select a function to call via overload resolution ([over.match]) on a candidate set that includes the lookup set found by argument dependent lookup ([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]

Date: 2021-10-31.00:00:00

The rule in [contents] means that the calls to make_error_code in [syserr.errcode.constructors] and [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 [syserr.errcondition.constructors] and [syserr.errcondition.modifiers].

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

Date User Action Args
2021-10-31 18:56:02adminsetmessages: + msg12203
2021-10-31 00:00:00admincreate