Topic: New <system_error> header leads to name clashes
Author: =?iso-8859-1?q?Daniel_Kr=FCgler?= <daniel.kruegler@googlemail.com>
Date: Sun, 24 Jun 2007 12:39:36 CST Raw View
The most recent state of
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2241.html
as well as the current draft N2284 (section [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 [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 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2213.pdf.
But maybe the forbidden implicit conversion to integral types would
make
these enumerators less attractive in this special case?
Greetings from Bremen,
Daniel Kr gler
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]