【发布时间】:2014-01-02 13:31:58
【问题描述】:
我从文件 utility(它位于 C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ 中收到一个我无法理解的奇怪错误(因为它来自 VS 的本机文件) >),它正在我的项目中使用 Visual C++ 10.0 编译。
'std::forward' : 无法将参数 1 从 '' 转换为 '&'
template<class _Other1, class _Other2>
pair(_Other1&& _Val1, _Other2&& _Val2)
: _Mybase(_STD forward<_Other1>(_Val1), _STD forward<_Other2>(_Val2))
{ // construct from moved values
}
谁能解释这个错误?在我看来这很奇怪,但我对 C++ 完全陌生,我不明白如何解决它。
错误似乎在这里:
std::map<std::string, DWORD>::value_type("SOME_STRING", 8192);
编译报告如下:
see reference to function template instantiation
'std::pair<_Ty1,_Ty2>::pair<const char(&)[12],>(_Other1,_Other2 &&)'
being compiled with
[
_Ty1=const std::string,
_Ty2=DWORD,
_Other1=const char (&)[12],
_Other2=
]
【问题讨论】:
-
请发布更完整的代码。
-
我们需要查看您的代码,而不是标准库的代码。
-
SSCCE 是理想的选择。
-
@LightStyle 另请注意,模板错误通常看起来像“在此处实例化 GHI 时实例化 DEF 时实例化 ABC 时出现错误 XYZ:
your_file_and_line.cpp” 要查找错误原因,您必须查看your_file_and_line.cpp,不是ABC。 -
很遗憾,我无法在 VS2010 上进行测试,但尝试将其替换为
std::make_pair(std::string("SOME_STRING"), 8192)
标签: c++ visual-studio-2010 templates compiler-errors std