static const map<const Type*, int>* priority;
其中Type是我自己的特殊类。
初始化(为什么c ++要求这个我不知道,auto甚至不工作)
const map<const Type*, int, less<const Type*>, allocator<pair<const Type* const, int>>>* ToolProperty::priority
= new map<const Type*, int, less<const Type*>, allocator<pair<const Type* const, int>>>();
最后,尝试使用它(它告诉我我传的错误类型)
static void setPriority(const Type* type, int newPriority)
{
(*priority)[type] = newPriority;
}
答案 0 :(得分:5)
priority是指向const映射的指针,但operator []不能与const associative containers
一起使用。