Questions tagged «enum-class»

7
如何在C ++ 11中输出枚举类的值
如何enum class在C ++ 11中输出an的值?在C ++ 03中,它是这样的: #include <iostream> using namespace std; enum A { a = 1, b = 69, c= 666 }; int main () { A a = A::c; cout << a << endl; } 在c ++ 0x中,此代码无法编译 #include <iostream> using namespace std; enum class A { a …


7
不能将枚举类用作unordered_map键
我有一个包含枚举类的类。 class Shader { public: enum class Type { Vertex = GL_VERTEX_SHADER, Geometry = GL_GEOMETRY_SHADER, Fragment = GL_FRAGMENT_SHADER }; //... 然后,当我在另一个类中实现以下代码时... std::unordered_map<Shader::Type, Shader> shaders; ...我得到一个编译错误。 ...usr/lib/c++/v1/type_traits:770:38: Implicit instantiation of undefined template 'std::__1::hash<Shader::Type>' 这是什么导致错误?
77 c++  c++11  map  enums  enum-class 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.