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>
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.
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 returnerror_code(static_cast<int>(val), cat)
, wherecat
is anerror_category
that describes typeT
.
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 returnerror_condition(static_cast<int>(val), cat)
, wherecat
is anerror_category
that describes typeT
.
Change 19.4.2.1 Class error_code overview [syserr.errcode.overview], class error_code synopsis:
template <classErrorCodeEnum E> error_code(ErrorCodeEnumE e,typename enable_if<is_error_code_enum<ErrorCodeEnum>::value>::type * = 0); ... template <classErrorCodeEnum E>typename enable_if<is_error_code_enum<ErrorCodeEnum>::value>::type&error_code& operator=(ErrorCodeEnumE e);
Change 19.4.2.2 Class error_code constructors [syserr.errcode.constructors]:
template <classErrorCodeEnum E> error_code(ErrorCodeEnumE 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 <classErrorCodeEnum E>typename enable_if<is_error_code_enum<ErrorCodeEnum>::value>::type&error_code& operator=(ErrorCodeEnumE e);
Change 19.4.3.1 Class error_condition overview [syserr.errcondition.overview], class error_condition synopsis:
template <classErrorConditionEnum E> error_condition(ErrorConditionEnumE e,typename enable_if<is_error_code_enum<ErrorConditionEnum>::value>::type * = 0); ... template <classErrorConditionEnum E>typename enable_if<is_error_condition_enum<ErrorConditionEnum>::value>::type&error_condition& operator=(ErrorConditionEnumE e);
Change 19.4.3.2 Class error_condition constructors [syserr.errcondition.constructors]:
template <classErrorConditionEnum E> error_condition(ErrorConditionEnumE 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 <classErrorConditionEnum E>typename enable_if<is_error_condition_enum<ErrorConditionEnum>::value>::type&error_condition& operator=(ErrorConditionEnumE e);
[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.