没有任何上下文的map(185)中的预期常量表达式 [英] Expected constant expression in map(185) without any context
问题描述
在评估我们迁移到Visual Studio 2017时,我遇到了一个模糊的错误消息C2057:期望在map中的常量表达式(825):(标准库实现在Visual Studio中)
while evaluating our move to Visual Studio 2017 I came across an obscure error message C2057: expected constant expression in map(825): (the standard library implementation within Visual Studio)
map& operator=(map&& _Right)
>>> _NOEXCEPT_COND(_Alnode_traits::is_always_equal::value
&& is_nothrow_move_assignable_v<_Pr>)
{ // assign by moving _Right
_Mybase::operator=(_STD move(_Right));
return (*this);
}
显然非常量表达式位于_NOEXCEPT_COND参数中的某处。由于没有解释,也没有给出上下文(模板的类型,实例化的地方或其他任何内容),到目前为止我们唯一的解决方案是切换到另一个容器
实现。
Apparently the non-constant-expression is somewhere in the _NOEXCEPT_COND parameters. As there is no explanation and no context (types for the template, place of instantiation or anything else) given, our only solution so far is to switch to a different container
implementation.
产生此错误的已编译源文件包含模板化类的特化,其中包含2个map< int,TYPE>并映射< int,int>。编译因该类的任何特化而失败。
The compiled source file producing this error contains specializations of a templated class that contains 2 map<int, TYPE> and map<int,int>. Compilation fails with any specialization of that class.
模板类没有明确的move-constructor,即使使用默认的分配器也会失败。
The template class has no explicit move-constructor and it fails even when using the default allocator.
有没有其他人在地图中遇到此错误?为什么没有上下文?
Has anyone else encountered this error inside map? Why is there no context given?
推荐答案
感谢您在此处发帖。
>>显然非常量表达式位于_NOEXCEPT_COND参数中的某个位置。由于没有解释,也没有给出上下文(模板的类型,实例化的地方或其他任何内容),到目前为止我们唯一的解决方案是将
切换到不同的容器实现。
产生此错误的已编译源文件包含模板化类的特化,其中包含2个map< int,TYPE>并映射< int,int>。编译因该类的任何特化而失败。
模板类没有明确的move-constructor,即使使用默认的分配器也会失败。
请提供有关导致此错误的模板类的详细信息。
Please provide more information about your template class which causes this error.
如果您能为我们提供重现样本,那么它会更好你的问题。
Or it will be better if you could provide us a sample to reproduce your issue.
这是一个类似的案例,也许你可以参考这个案例并等待微软的回复。
Here is a similar case, maybe you could refer to this case and wait for the response from the Microsoft.
希望这可以帮到你。
最好的问候,
Baron Bi
Baron Bi
这篇关于没有任何上下文的map(185)中的预期常量表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!