This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Resolved status.
<system_error>
header leads to name clashesSection: 19.5 [syserr] Status: Resolved Submitter: Daniel Krügler Opened: 2007-06-24 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [syserr].
View all issues with Resolved status.
Discussion:
The most recent state of
N2241
as well as the current draft
N2284
(section 19.5 [syserr], p.2) proposes a
new
enumeration type posix_errno
immediatly in the namespace std
. One of
the enumerators has the name invalid_argument
, or fully qualified:
std::invalid_argument
. This name clashes with the exception type
std::invalid_argument
, see 19.2 [std.exceptions]/p.3. This clash makes
e.g. the following snippet invalid:
#include <system_error> #include <stdexcept> void foo() { throw std::invalid_argument("Don't call us - we call you!"); }
I propose that this enumeration type (and probably the remaining parts
of
<system_error>
as well) should be moved into one additional inner
namespace, e.g. sys
or system
to reduce foreseeable future clashes
due
to the great number of members that std::posix_errno
already contains
(Btw.: Why has the already proposed std::sys
sub-namespace from
N2066
been rejected?). A further clash candidate seems to be
std::protocol_error
(a reasonable name for an exception related to a std network library,
I guess).
Another possible resolution would rely on the proposed strongly typed enums, as described in N2213. But maybe the forbidden implicit conversion to integral types would make these enumerators less attractive in this special case?
Proposed resolution:
Fixed by issue 7 of N2422.