Unordered_map静态断言失败

unordered_map static assertion failed

本文关键字:断言 失败 静态 map Unordered      更新时间:2023-10-16

由于静态断言失败错误,无法声明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;