由于静态断言失败错误,我无法声明 unordered_map。首先,什么是静态断言?我搜索了答案,但我无法理解文档。这是声明:
std::unordered_map<Point3D<int>, int> tree;
这是 Point3D 结构
template <class T>
struct Point3D
{
public:
T x, y, z;
Point3D(T _x, T _y, T _z) : x(_x), y(_y), z(_z)
{
}
};
我可以或应该怎么做才能让它发挥作用?
谢谢! :)
最佳答案
这对我来说在 Visual Studio 2010 下编译正常:
#include <unordered_map>
template <class T>
struct Point3D
{
public:
T x, y, z;
Point3D(T _x, T _y, T _z) : x(_x), y(_y), z(_z)
{
}
};
std::unordered_map<Point3D<int>, int> tree;
关于c++ - unordered_map 静态断言失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22286975/