小编Vya*_*sky的帖子

Why this code provides specialization for **ALL** enums for std::hash template?

I'm not a pro in C++ but somehow I provided a solution while porting my MSVS 2015 C++ code to MinGW 4.9.2 to specialize std::hash class to support all enums. It there's any C++ compiler developers or C++ pro programmers here, can you explain why this specialization works, although it is Undefined Behavior according the C++ standard they say?

Link for full code with samples on Gist

#include <unordered_set>
#include <functional>

#if (defined __GNUC__) && (__GNUC__ < 6)
// …
Run Code Online (Sandbox Code Playgroud)

c++ enums gcc c++11 stdhash

0
推荐指数
1
解决办法
411
查看次数

标签 统计

c++ ×1

c++11 ×1

enums ×1

gcc ×1

stdhash ×1