Title
posix_error::posix_errno concerns
Status
cd1
Section
[syserr]
Submitter
Jens Maurer

Created on 2008-02-24.00:00:00 last changed 164 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

Names Considered
portable Too non-specific. Did not wish to reserve such a common word in namespace std. Not quite the right meaning, either.
portable_error Too long. Explicit qualification is always required for scoped enums, so a short name is desirable. Not quite the right meaning, either. May be misleading because *_error in the std lib is usually an exception class name.
std_error Fairly short, yet explicit. But in fully qualified names like std::std_error::not_enough_memory, the std_ would be unfortunate. Not quite the right meaning, either. May be misleading because *_error in the std lib is usually an exception class name.
generic Short enough. The category could be generic_category. Fully qualified names like std::generic::not_enough_memory read well. Reserving in namespace std seems dicey.
generic_error Longish. The category could be generic_category. Fully qualified names like std::generic_error::not_enough_memory read well. Misleading because *_error in the std lib is usually an exception class name.
generic_err A bit less longish. The category could be generic_category. Fully qualified names like std::generic_err::not_enough_memory read well.
gen_err Shorter still. The category could be generic_category. Fully qualified names like std::gen_err::not_enough_memory read well.
generr Shorter still. The category could be generic_category. Fully qualified names like std::generr::not_enough_memory read well.
error Shorter still. The category could be generic_category. Fully qualified names like std::error::not_enough_memory read well. Do we want to use this general a name?
err Shorter still. The category could be generic_category. Fully qualified names like std::err::not_enough_memory read well. Although alone it looks odd as a name, given the existing errno and namespace std names, it seems fairly intuitive. Problem: err is used throughout the standard library as an argument name and in examples as a variable name; it seems too confusing to add yet another use of the name.
errc Short enough. The "c" stands for "constant". The category could be generic_category. Fully qualified names like std::errc::not_enough_memory read well. Although alone it looks odd as a name, given the existing errno and namespace std names, it seems fairly intuitive. There are no uses of errc in the current C++ standard.
Date: 2010-10-21.18:28:33

Proposed resolution:

Change System error support [syserr] as indicated:

namespace posix_error {
  enum posix_errno class errc {
    address_family_not_supported, // EAFNOSUPPORT
    ...
    wrong_protocol_type, // EPROTOTYPE
  };
} // namespace posix_error

template <> struct is_error_condition_enum<posix_error::posix_errno errc>
  : public true_type {}

namespace posix_error {
  error_code make_error_code(posix_errno errc e);
  error_condition make_error_condition(posix_errno errc e);
} // namespace posix_error

Change System error support [syserr] :

The is_error_code_enum and is_error_condition_enum templates may be specialized for user-defined types to indicate that such a type is eligible for class error_code and class error_condition automatic conversions, respectively.

Change System error support [syserr] and its subsections:

  • remove all occurrences of posix_error::
  • change all instances of posix_errno to errc
  • change all instances of posix_category to generic_category
  • change all instances of get_posix_category to get_generic_category

Change Error category objects [syserr.errcat.objects], paragraph 2:

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 "POSIX" "generic".

Change [syserr.errcode.nonmembers] Class error_code non-member functions as indicated:

error_code make_error_code(posix_errno errc e);

Returns: error_code(static_cast<int>(e), posixgeneric_category).

Change [syserr.errcondition.nonmembers] Class error_condition non-member functions as indicated:

error_condition make_error_condition(posix_errno errc e);

Returns: error_condition(static_cast<int>(e), posixgeneric_category).

Date: 2010-10-21.18:28:33

[ Further discussion: ]

See N2347, Strongly Typed Enums, since renamed Scoped Enums.

Alberto Ganesh Barbati also raised this issue in private email, and also proposed the scoped-enum solution.

Nick Stoughton asked in Bellevue that posix_error and posix_errno not be used as names. The LWG agreed.

The wording for the Proposed resolution was provided by Beman Dawes.

Date: 2008-02-24.00:00:00

[syserr]

namespace posix_error {
  enum posix_errno {
    address_family_not_supported, // EAFNOSUPPORT
    ...

should rather use the new scoped-enum facility ([dcl.enum]), which would avoid the necessity for a new posix_error namespace, if I understand correctly.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg3839
2010-10-21 18:28:33adminsetmessages: + msg3838
2010-10-21 18:28:33adminsetmessages: + msg3837
2008-02-24 00:00:00admincreate