Created on 2008-05-14.00:00:00 last changed 171 months ago
[ San Francisco: ]
NAD because Beman said so.
Proposed resolution:
The proposed wording assumes the LWG 805 proposed wording has been applied to the WP, resulting in the former posix_category being renamed generic_category. If 805 has not been applied, the names in this proposal must be adjusted accordingly.
Change [syserr.errcat.overview] Class error_category overview error_category synopsis as indicated:
const error_category& get_generic_category();const error_category& get_system_category();staticextern const error_category&* const generic_category= get_generic_category();staticextern const error_category&* constnative_categorysystem_category= get_system_category();
Change [syserr.errcat.objects] Error category objects as indicated:
extern const error_category&* constget_generic_category();
Returns: A referencegeneric_category shall point toana statically initialized object of a type derived from class error_category.
Remarks:The object's default_error_condition and equivalent virtual functions shall behave as specified for the class error_category. The object's name virtual function shall return a pointer to the string "GENERIC".extern const error_category&* constget_system_category();
Returns: A referencesystem_category shall point toana statically initialized object of a type derived from class error_category.
Remarks:The object's equivalent virtual functions shall behave as specified for class error_category. The object's name virtual function shall return a pointer to the string "system". The object's default_error_condition virtual function shall behave as follows:If the argument ev corresponds to a POSIX errno value posv, the function shall return error_condition(posv, generic_category). Otherwise, the function shall return error_condition(ev, system_category). What constitutes correspondence for any given operating system is unspecified. [Note: The number of potential system error codes is large and unbounded, and some may not correspond to any POSIX errno value. Thus implementations are given latitude in determining correspondence. -- end note]
Change [syserr.errcode.overview] Class error_code overview as indicated:
class error_code { public: ...; constexpr error_code(int val, const error_category&* cat); ... void assign(int val, const error_category&* cat); ... const error_category&* category() const; ... private: int val_; // exposition only const error_category&* cat_; // exposition only
Change [syserr.errcode.constructors] Class error_code constructors as indicated:
constexpr error_code(int val, const error_category&* cat);Effects: Constructs an object of type error_code.
Postconditions: val_ == val and cat_ == cat.
Throws: Nothing.
Change [syserr.errcode.modifiers] Class error_code modifiers as indicated:
void assign(int val, const error_category&* cat);Postconditions: val_ == val and cat_ == cat.
Throws: Nothing.
Change [syserr.errcode.observers] Class error_code observers as indicated:
const error_category&* category() const;Returns: cat_.
Throws: Nothing.
Change [syserr.errcondition.overview] Class error_condition overview as indicated:
class error_condition { public: ...; constexpr error_condition(int val, const error_category&* cat); ... void assign(int val, const error_category&* cat); ... const error_category&* category() const; ... private: int val_; // exposition only const error_category&* cat_; // exposition only
Change [syserr.errcondition.constructors] Class error_condition constructors as indicated:
constexpr error_condition(int val, const error_category&* cat);Effects: Constructs an object of type error_condition.
Postconditions: val_ == val and cat_ == cat.
Throws: Nothing.
Change [syserr.errcondition.modifiers] Class error_condition modifiers as indicated:
void assign(int val, const error_category&* cat);Postconditions: val_ == val and cat_ == cat.
Throws: Nothing.
Change [syserr.errcondition.observers] Class error_condition observers as indicated:
const error_category&* category() const;Returns: cat_.
Throws: Nothing.
Throughout [syserr] System error support, change "category()." to "category()->". Appears approximately six times.
[Partially Editorial] In [syserr.compare] Comparison operators, paragraphs 2 and 4, change "category.equivalent(" to "category()->equivalent(".
Change [syserr.syserr.overview] Class system_error overview as indicated:
public: system_error(error_code ec, const string& what_arg); system_error(error_code ec); system_error(int ev, const error_category&* ecat, const string& what_arg); system_error(int ev, const error_category&* ecat);
Change [syserr.syserr.members] Class system_error members as indicated:
system_error(int ev, const error_category&* ecat, const string& what_arg);Effects: Constructs an object of class system_error.
Postconditions: code() == error_code(ev, ecat) and strcmp(runtime_error::what(), what_arg.c_str()) == 0.
system_error(int ev, const error_category&* ecat);Effects: Constructs an object of class system_error.
Postconditions: code() == error_code(ev, ecat) and strcmp(runtime_error::what(), "") == 0.
[ Pre-San Francisco: ]
Beman Dawes reports that this proposal is unimplementable, and thus NAD.
Implementation would require constexpr objects of classes derived from class error_category, which has virtual functions, and that is not allowed by the core language. This was determined when trying to implement the proposal using a constexpr enabled compiler provided by Gabriel Dos Reis, and subsequently verified in discussions with Gabriel and Jens Maurer.
[ Sophia Antipolis: ]
On going question of extern pointer vs. inline functions for interface.
Initialization of objects of class error_code ([syserr.errcode]) and class error_condition ([syserr.errcondition]) can be made simpler and more reliable by use of the new constexpr feature [N2349] of C++0x. Less code will need to be generated for both library implementations and user programs when manipulating constant objects of these types.
This was not proposed originally because the constant expressions proposal was moving into the standard at about the same time as the Diagnostics Enhancements proposal [N2241], and it wasn't desirable to make the later depend on the former. There were also technical concerns as to how constexpr would apply to references. Those concerns are now resolved; constexpr can't be used for references, and that fact is reflected in the proposed resolution.
Thanks to Jens Maurer, Gabriel Dos Reis, and Bjarne Stroustrup for clarification of constexpr requirements.
LWG issue 804 is related in that it raises the question of whether the exposition only member cat_ of class error_code ([syserr.errcode]) and class error_condition ([syserr.errcondition]) should be presented as a reference or pointer. While in the context of 804 that is arguably an editorial question, presenting it as a pointer becomes more or less required with this proposal, given constexpr does not play well with references. The proposed resolution thus changes the private member to a pointer, which also brings it in sync with real implementations.
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-10-21 18:28:33 | admin | set | messages: + msg3972 |
2010-10-21 18:28:33 | admin | set | messages: + msg3971 |
2010-10-21 18:28:33 | admin | set | messages: + msg3970 |
2010-10-21 18:28:33 | admin | set | messages: + msg3969 |
2008-05-14 00:00:00 | admin | create |