[cfe-dev] std::error_category not extensible?

Howard Hinnant hhinnant at apple.com
Sun Dec 16 20:03:33 PST 2012


On Dec 16, 2012, at 10:14 PM, Howard Hinnant <hhinnant at apple.com> wrote:

> 
> On Dec 16, 2012, at 9:29 PM, Gordon Henriksen <gordonhenriksen at me.com> wrote:
> 
>> We have a reasonably large body of code using std::error_category subclasses on Visual C++. With libc++, error_category::error_category() is private, preventing this code from porting. Was there a late decision by the standards committee to redact system_error extensibility...?
>> 
>> — Gordon
>> 
>> 
>> 
>> 
>> class _LIBCPP_VISIBLE error_category
>> {
>> public:
>>   virtual ~error_category() _NOEXCEPT;
>> 
>> private:
>>   error_category() _NOEXCEPT;
>>   error_category(const error_category&);// = delete;
>>   error_category& operator=(const error_category&);// = delete;
>> 
>> public:
>>   virtual const char* name() const _NOEXCEPT = 0;
>>   virtual error_condition default_error_condition(int __ev) const _NOEXCEPT;
>>   virtual bool equivalent(int __code, const error_condition& __condition) const _NOEXCEPT;
>>   virtual bool equivalent(const error_code& __code, int __condition) const _NOEXCEPT;
>>   virtual string message(int __ev) const = 0;
>> 
>>   _LIBCPP_ALWAYS_INLINE
>>   bool operator==(const error_category& __rhs) const _NOEXCEPT {return this == &__rhs;}
>> 
>>   _LIBCPP_ALWAYS_INLINE
>>   bool operator!=(const error_category& __rhs) const _NOEXCEPT {return !(*this == __rhs);}
>> 
>>   _LIBCPP_ALWAYS_INLINE
>>   bool operator< (const error_category& __rhs) const _NOEXCEPT {return this < &__rhs;}
>> 
>>   friend class __do_message;
>> };
>> 
>> class _LIBCPP_HIDDEN __do_message
>>   : public error_category
>> {
>> public:
>>   virtual string message(int ev) const;
>> };
> 
> This is a defect in C++11 tracked by:
> 
> http://cplusplus.github.com/LWG/lwg-active.html#2145
> 
> which is in Ready status.  That means it hasn't been voted in yet, but looks likely to be voted in at the next meeting Spring 2013.
> 
> Tip-of-trunk libc++ has aggressively tracked this issue and implemented it even though it hasn't been officially accepted yet.  However because llvm servers are currently less than functional, I'm unable to pinpoint the precise revision this was checked in.
> 
> The fix involves simply making the existing error_category default constructor public.


llvm is back up:

> r153194 | hhinnant | 2012-03-21 12:18:57 -0400 (Wed, 21 Mar 2012) | 1 line
> 
> It appears that the standard accidentally removed the default constructor for error_category.  I'm putting it back in.  This fixes http://llvm.org/bugs/show_bug.cgi?id=12321.

Howard





More information about the cfe-dev mailing list