C2995:功能模板已定义。 [英] C2995: function template has already been defined.

查看:136
本文介绍了C2995:功能模板已定义。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误C2995:

'std :: basic_string< _Elem,_Traits,_Alloc> std :: operator +(const std :: basic_string< _Elem,_Traits,_Alloc>&,const std :: basic_string< _Elem

,_Traits,_Alloc>&)':函数模板已经已定义



错误C2995:

'std :: basic_string< _Elem,_Traits,_Alloc> std :: operator +(const _Elem * const,const std :: basic_string< _Elem,_Traits,_Alloc>&)':函数模板已经定义

.....等



我得到23个这样的错误。这个错误是什么意思?



我正在转换这个项目从视觉工作室2008到视觉工作室2017.代码正在编译和建设在2008年的罚款,但在vs2017它会给出这样的错误。任何人都帮我解决这个错误?



我尝试过:



错误C2382:'std :: operator> =':redefinition;不同的异常规格



i我也得到这个错误。这个错误的含义是什么。

error C2995:
'std::basic_string<_Elem,_Traits,_Alloc> std::operator +(const std::basic_string<_Elem,_Traits,_Alloc> &,const std::basic_string<_Elem
,_Traits,_Alloc> &)': function template has already been defined

error C2995:
'std::basic_string<_Elem,_Traits,_Alloc> std::operator +(const _Elem *const ,const std::basic_string<_Elem,_Traits,_Alloc> &)': function template has already been defined
.....etc.

I am getting 23 errors like this.what is this error mean?

I am converting this project from visual studio 2008 to visual studio 2017.The code is compiling and building fine in vs 2008 but in vs2017 it is giving errors like this.can anyone help me to solve this error?

What I have tried:

error C2382: 'std::operator >=': redefinition; different exception specifications

i am getting this error also.what are the meanings of this error.

推荐答案

这意味着您在不同的包含文件中具有相同的模板声明,这些声明都包含在一个源文件中。



如果没有看到包含哪些文件,很难提供帮助生成错误的源文件以及这些文件所在的位置。



但错误

It means that you have the same template declarations in different include files which are all included by one source file.

It is difficult to help without seeing which files are included by the source file generating the errors and where these files are located.

But the error
error C2382: 'std::operator >=': redefinition; different exception specifications

包含一个提示:它不仅是一个重新定义,而且是一个不同的声明(关于异常)。这可能表示您包含来自不同SDK / VS版本的头文件或包含相同定义的(第三方)头文件(例如,使用条件但未能检测到VS 2017)。



错误中的模板在 string 头文件中定义(不带 .h 扩展名)。因此,您应检查新SDK / VS版本是否包含该内容,并搜索其他包含的文件以获得相同的定义。





contains a hint: It is not only a redefinition but also a different declaration (regarding exceptions). That might indicate that you are including headers from different SDK / VS versions or (third party) header files that contain the same definitions (e.g. with conditionals but fail to detect VS 2017).

The templates from the errors are defined in the string header file (without .h extension). So you should check if that is included from the new SDK / VS version and search the other included files for the same definitions.


引用注释:

和我使用vs2017版本仅包含文件(xstring),其中包含那些模板声明。

and i used vs2017 version include file only(xstring)which contains those template declarations.

从不包含< I> xstring 的。请改为包含 字符串 xstring 是一个MS / VS特定(非标准)头文件,由 string 包含。

[/ EDIT]

Never include xstring. Include string instead. xstring is a MS / VS specific (non standard) header file that is included by string.
[/EDIT]


这篇关于C2995:功能模板已定义。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆