草庐IT

TYPE_STEP_COUNTER

全部标签

C++:错误 "... is not derived from type ..."

templateclassBimap{public:classData;typedefData*DataP;typedefstd::multimapT1Map;typedefstd::multimapT2Map;classData{private:Bimap&bimap;T1Map::iteratorit1;/*...*/};};这给了我这个编译错误:error:type'std::multimap::Data*,std::less,std::allocator::Data*>>>'isnotderivedfromtype'Bimap::Data'这是什么意思?这里有什么问题?

C++ 错误 : 'unordered_map' does not name a type

据我所知,我所做的一切都是正确的,并且我收到了错误消息:error:'unordered_map'doesnotnameatypeerror:'mymap'doesnotnameatype在我的代码中,我有:#includeusingnamespacestd;//globalvariableunordered_mapmymap;mymap.reserve(7000);voidmain{return;}我看不出这里可能缺少什么......编辑:当我将声明更新为std::tr1::unordered_mapmymap;我能够消除第一个错误,但是当我尝试保留时,我仍然收到第二个错误消息。ED

C++ 错误 : 'unordered_map' does not name a type

据我所知,我所做的一切都是正确的,并且我收到了错误消息:error:'unordered_map'doesnotnameatypeerror:'mymap'doesnotnameatype在我的代码中,我有:#includeusingnamespacestd;//globalvariableunordered_mapmymap;mymap.reserve(7000);voidmain{return;}我看不出这里可能缺少什么......编辑:当我将声明更新为std::tr1::unordered_mapmymap;我能够消除第一个错误,但是当我尝试保留时,我仍然收到第二个错误消息。ED

c++ - C++ 中的 "Y does not name a type"错误

我不知道要搜索什么才能找到对此的解释,所以我问。我有这个报告错误的代码:structSettings{intwidth;intheight;}settings;settings.width=800;//'settings'doesnotnameatypeerrorsettings.height=600;//'settings'doesnotnameatypeerrorintmain(){cout但如果我将值赋值放在main中,它会起作用:structSettings{intwidth;intheight;}settings;main(){settings.width=800;//noe

c++ - C++ 中的 "Y does not name a type"错误

我不知道要搜索什么才能找到对此的解释,所以我问。我有这个报告错误的代码:structSettings{intwidth;intheight;}settings;settings.width=800;//'settings'doesnotnameatypeerrorsettings.height=600;//'settings'doesnotnameatypeerrorintmain(){cout但如果我将值赋值放在main中,它会起作用:structSettings{intwidth;intheight;}settings;main(){settings.width=800;//noe

c++ - 为什么 cppreference 将 type_traits xxx_v 快捷方式定义为内联 constexpr 而不仅仅是 constexpr?

为什么cppreference将type_traitsxxx_v快捷方式定义为inlineconstexpr而不仅仅是constexpr?例如,参见is_integral_v:templateinlineconstexprboolis_integral_v=is_integral::value;这只是风格问题还是行为上有一些差异?据我所知constexpr变量是隐式inline.编辑:查看最新标准的草案,它也使用inlineconstexpr。那么这个问题实际上适用于标准。 最佳答案 [dcl.constexpr]/9Aconste

c++ - 为什么 cppreference 将 type_traits xxx_v 快捷方式定义为内联 constexpr 而不仅仅是 constexpr?

为什么cppreference将type_traitsxxx_v快捷方式定义为inlineconstexpr而不仅仅是constexpr?例如,参见is_integral_v:templateinlineconstexprboolis_integral_v=is_integral::value;这只是风格问题还是行为上有一些差异?据我所知constexpr变量是隐式inline.编辑:查看最新标准的草案,它也使用inlineconstexpr。那么这个问题实际上适用于标准。 最佳答案 [dcl.constexpr]/9Aconste

c++ - 调试断言失败…_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)

我正在尝试修复一个非常严重的内存泄漏,但不知何故我无法在不触发此断言的情况下删除对象。我已通过Google搜索了解决方案,并已阅读有关此错误的Stackoverflow上的问题,但我仍然无法找到答案!根据我的研究,出现此错误的可能原因:1.删除多个对象2.影子复制3.创建和删除从外部dll加载的对象4.创建对象而不存储指针但是:1.我检查了代码,没有找到双重删除2.我使用拷贝构造函数来拷贝Objects3.错误相关类(使用MSVisualStudio)构建到单独的库而不是dll。并且与此错误相关的所有类都位于同一个库中。4.我检查了代码,似乎不是问题如果有人能够在下面的代码中发现错误,

c++ - 调试断言失败…_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)

我正在尝试修复一个非常严重的内存泄漏,但不知何故我无法在不触发此断言的情况下删除对象。我已通过Google搜索了解决方案,并已阅读有关此错误的Stackoverflow上的问题,但我仍然无法找到答案!根据我的研究,出现此错误的可能原因:1.删除多个对象2.影子复制3.创建和删除从外部dll加载的对象4.创建对象而不存储指针但是:1.我检查了代码,没有找到双重删除2.我使用拷贝构造函数来拷贝Objects3.错误相关类(使用MSVisualStudio)构建到单独的库而不是dll。并且与此错误相关的所有类都位于同一个库中。4.我检查了代码,似乎不是问题如果有人能够在下面的代码中发现错误,

c++ - 此错误消息是否正确 : non-type template argument is not a constant expression

以下程序可以使用GCC5.2编译,但不能使用clang3.6:constexprboolflag();templateconstexprbooltest(){returnb;}intmain(){}我用clang得到的错误信息是:main.cpp:3:20:error:non-typetemplateargumentisnotaconstantexpressiontemplate^~~~~~main.cpp:3:20:note:undefinedfunction'flag'cannotbeusedinaconstantexpressionmain.cpp:1:16:note:decla