Patch for LWG issue #2148

Howard Hinnant hhinnant at apple.com
Tue Sep 3 08:00:54 PDT 2013


On Sep 3, 2013, at 10:16 AM, Marshall Clow <mclow.lists at gmail.com> wrote:

> 
> On Aug 29, 2013, at 1:55 PM, Howard Hinnant <hhinnant at apple.com> wrote:
> 
>> On Aug 28, 2013, at 11:17 AM, Marshall Clow <mclow.lists at gmail.com> wrote:
>> 
>>> Issue 2148 adds std::hash behavior for enumerations.
>>> Add this support, and a test case.
>> 
>> We shouldn't make the assumption in the test that hash<integral>{}(i) == i.  Instead the test should get the underlying type of the enum and assert(h(t) == std::hash<underlying_type>{}(static_cast<underlying_type>(i))).
>> 
>> Also could you test an unscoped enum as well.
> 
> Done and done.
> 
>> And could you add a .fail to make sure the std::hash<X>{}(x) for some struct X {}.  We should've had this before and don't.  So don't put the .fail under _LIBCPP_STD_VER > 11.
> 
> I put it under a __cplusplus >= 201103L instead, since there's no hash in C++03.
> 
> Updated patch attached.

libc++ has no C++03 mode.  When -std=c++03, libc++ goes to extra effort to supply C++11 library features.  The rationale for this design is that there were already plenty of C++03-conforming std::libs available.

Howard




More information about the cfe-commits mailing list