Document number:       N2620=08-0130
Date:                            2008-05-19
Project:                        Programming Language C++, Library Working Group
Reply-to:                      Beman Dawes <bdawes at acm.org>
                                    Daniel Krügler <daniel.kruegler at googlemail.com>
                                    Douglas Gregor <dgregor at cs.indiana.edu>

Concepts for the C++0x Standard Library: Diagnostics library

Introduction

This document proposes changes to Chapter 19 of the C++ Standard Library in order to make full use of concepts [1]. A prototype of the proposed resolution wording has been implemented and tested using ConceptGCC. Because the only component affected is new to C++0x, there is no issue of backward compatibility.

This document is formatted in the same manner as the working draft of the C++ standard. Future versions of this document will track the working draft and the concepts proposal as they evolve. Proposed changes to the working paper provide enough current text to supply context, but only red current text with strikethrough is to be deleted, and only blue-green text with underscore is to be added, unless editorial comments state otherwise. Editorial comments are in italics.

Proposed wording

The proposed wording assumes LWG 805, posix_error::posix_errno concerns, has been accepted and its proposed wording applied to the WP. If resolution of that issue changes the name posix_errno to some name other than errc, the wording of this proposal should be applied with the new name (in two places).

If LWG 805 has not been applied, all uses of  errc should be changed to posix_error::posix_errno  and the namespace around the make_error_code/make_condition_code set of functions should be removed.

The proposed wording assumes LWG 832, Applying constexpr to System error support, has been accepted and its proposed wording applied to the WP. If it has not been accepted, strike constexpr from this proposal (in two places).

Change 19.4 System error support [syserr], Header <system_error> synopsis:

template <class T>
struct is_error_code_enum : public false_type {};

template <class T>
struct is_error_condition_enum : public false_type {};

concept ErrorCodeEnum<typename T> see below

concept ErrorConditionEnum<typename T> see below

...

template <> struct is_error_condition_enum<errc>
  : public true_type {}

concept_map ErrorConditionEnum<errc> {};

At a location to be determined by the Project Editor, insert:

concept ErrorCodeEnum<typename T> : EnumerationType<T> {
  constexpr error_code make_error_code(T val);
  }

Describes types to be used as an argument to function make_error_code.

Requires: Function make_error_code shall return error_code(static_cast<int>(val), cat), where cat is an error_category that describes type T.

concept ErrorConditionEnum<typename T> : EnumerationType<T> {
  constexpr error_condition make_error_condition(T val);
  }

Describes types to be used as an argument to function make_error_condition.

Requires: Function make_error_condition shall return error_condition(static_cast<int>(val), cat), where cat is an error_category that describes type T.

Change 19.4.2.1 Class error_code overview [syserr.errcode.overview], class error_code synopsis:

template <class ErrorCodeEnum E>
   error_code(ErrorCodeEnum E e,
     typename enable_if<is_error_code_enum<ErrorCodeEnum>::value>::type * = 0);

...

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

Change 19.4.2.2 Class error_code constructors [syserr.errcode.constructors]:

template <class ErrorCodeEnum E>
   error_code(ErrorCodeEnum E e,
     typename enable_if<is_error_code_enum<ErrorCodeEnum>::value>::type * = 0);

Change 19.4.2.3 Class error_code modifiers [syserr.errcode.modifiers]:

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

Change 19.4.3.1 Class error_condition overview [syserr.errcondition.overview], class error_condition synopsis:

template <class ErrorConditionEnum E>
   error_condition(ErrorConditionEnum E e,
     typename enable_if<is_error_code_enum<ErrorConditionEnum>::value>::type * = 0);

...

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

Change 19.4.3.2 Class error_condition constructors [syserr.errcondition.constructors]:

template <class ErrorConditionEnum E>
   error_condition(ErrorConditionEnum E e,
     typename enable_if<is_error_code_enum<ErrorConditionEnum>::value>::type * = 0);

Change 19.4.3.3 Class error_condition modifiers [syserr.errcondition.modifiers]:

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

Bibliography

[1] D. Gregor, B. Stroustrup, J. Siek, J. Widman. Proposed Wording for Concepts (Revision 5). Technical Report N2617=08-0127, ISO/IEC JTC 1, Information Technology, Subcommittee SC 22, Programming Language C++, May 2008.