1229. error_code operator= typo

Section: 22.5.3.3 [syserr.errcode.modifiers] Status: Resolved Submitter: Stephan T. Lavavej Opened: 2009-10-08 Last modified: 2016-02-10

Priority: Not Prioritized

View all issues with Resolved status.

Discussion:

N2960 22.5.3.1 [syserr.errcode.overview] and 22.5.3.3 [syserr.errcode.modifiers] say:

 
template <class ErrorCodeEnum>
  typename enable_if<is_error_code_enum<ErrorCodeEnum>::value>::type&
    operator=(ErrorCodeEnum e);

They should say:

 
template <class ErrorCodeEnum>
  typename enable_if<is_error_code_enum<ErrorCodeEnum>::value, error_code>::type&
    operator=(ErrorCodeEnum e);

Or (I prefer this form):

 
template <class ErrorCodeEnum>
  typename enable_if<is_error_code_enum<ErrorCodeEnum>::value, error_code&>::type
    operator=(ErrorCodeEnum e);

This is because enable_if is declared as (23.15.7.6 [meta.trans.other]):

 
template <bool B, class T = void> struct enable_if;

So, the current wording makes operator= return void&, which is not good.

22.5.3.3 [syserr.errcode.modifiers]/4 says

Returns: *this.

which is correct.

Additionally,

22.5.4.1 [syserr.errcondition.overview]/1 says:

 
template<typename ErrorConditionEnum>
  typename enable_if<is_error_condition_enum<ErrorConditionEnum>, error_code>::type &
    operator=( ErrorConditionEnum e );

Which contains several problems (typename versus class inconsistency, lack of ::value, error_code instead of error_condition), while 22.5.4.3 [syserr.errcondition.modifiers] says:

 
template <class ErrorConditionEnum>
  typename enable_if<is_error_condition_enum<ErrorConditionEnum>::value>::type&
    operator=(ErrorConditionEnum e);

Which returns void&. They should both say:

 
template <class ErrorConditionEnum>
  typename enable_if<is_error_condition_enum<ErrorConditionEnum>::value, 
  error_condition>::type&
    operator=(ErrorConditionEnum e);

Or (again, I prefer this form):

 
template <class ErrorConditionEnum>
  typename enable_if<is_error_condition_enum<ErrorConditionEnum>::value, 
  error_condition&>::type
    operator=(ErrorConditionEnum e);

Additionally, 22.5.4.3 [syserr.errcondition.modifiers] lacks a "Returns: *this." paragraph, which is presumably necessary.

[ 2009-10-18 Beman adds: ]

The proposed resolution for issue 1237 makes this issue moot, so it should become NAD.

[ 2009-10 Santa Cruz: ]

NADResolved, solved by 1237.

Proposed resolution:

Change 22.5.3.1 [syserr.errcode.overview] and 22.5.3.3 [syserr.errcode.modifiers]:

template <class ErrorCodeEnum>
  typename enable_if<is_error_code_enum<ErrorCodeEnum>::value, 
  error_code&>::type&
    operator=(ErrorCodeEnum e);

Change 22.5.4.1 [syserr.errcondition.overview]:

template<typename class ErrorConditionEnum>
  typename enable_if<is_error_condition_enum<ErrorConditionEnum>::value, 
  error_conditionde&>::type &
    operator=( ErrorConditionEnum e );

Change 22.5.4.3 [syserr.errcondition.modifiers]:

template <class ErrorConditionEnum>
  typename enable_if<is_error_condition_enum<ErrorConditionEnum>::value, 
  error_condition&>::type&
    operator=(ErrorConditionEnum e);

Postcondition: *this == make_error_condition(e).

Returns: *this.

Throws: Nothing.