Patch for LWG issue #2148

Marshall Clow mclow.lists at gmail.com
Tue Sep 3 07:16:28 PDT 2013


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.

-- Marshall

Marshall Clow     Idio Software   <mailto:mclow.lists at gmail.com>

A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
        -- Yu Suzuki
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ish2128-2.patch
Type: application/octet-stream
Size: 3687 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130903/911c9790/attachment.obj>


More information about the cfe-commits mailing list