Title
system_error needs const char* constructors
Status
cd1
Section
[syserr.syserr.overview]
Submitter
Daniel Krügler

Created on 2007-06-24.00:00:00 last changed 164 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

This proposed wording assumes issue 832 has been accepted and applied to the working paper.

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, const char* 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,
      const char* what_arg);
  system_error(int ev, const error_category* ecat);

To [syserr.syserr.members] Class system_error members add:

system_error(error_code ec, const char* what_arg);

Effects: Constructs an object of class system_error.

Postconditions: code() == ec and strcmp(runtime_error::what(), what_arg) == 0.

system_error(int ev, const error_category* ecat, const char* what_arg);

Effects: Constructs an object of class system_error.

Postconditions: code() == error_code(ev, ecat) and strcmp(runtime_error::what(), what_arg) == 0.

Date: 2007-06-24.00:00:00

In [syserr.syserr.overview] we have the class definition of std::system_error. In contrast to all exception classes, which are constructible with a what_arg string (see [std.exceptions], or ios_base::failure in [ios::failure]), only overloads with with const string& are possible. For consistency with the re-designed remaining exception classes this class should also provide c'tors which accept a const char* what_arg string.

Please note that this proposed addition makes sense even considering the given implementation hint for what(), because what_arg is required to be set as what_arg of the base class runtime_error, which now has the additional c'tor overload accepting a const char*.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg3470
2007-06-24 00:00:00admincreate