C++ 为什么在使用emplace方法处理无序地图时会出现编译错误? #包括 #包括 使用名称空间std; .... .... 无序映射哈希表; string str=“hello”; char lower=tolower(str[0]); hashtable.emplace(下,1); ....

C++ 为什么在使用emplace方法处理无序地图时会出现编译错误? #包括 #包括 使用名称空间std; .... .... 无序映射哈希表; string str=“hello”; char lower=tolower(str[0]); hashtable.emplace(下,1); ....,c++,hashtable,unordered-map,C++,Hashtable,Unordered Map,返回以下编译错误: #include <string> #include <unordered_map> using namespace std; .... .... unordered_map<char, int> hashtable; string str = "hello"; char lower = tolower(str[0]); hashtable.emplace(lower, 1); .... 1错误C2780:'std::pair std

返回以下编译错误:

#include <string>
#include <unordered_map>

using namespace std;

....
....
unordered_map<char, int> hashtable;
string str = "hello";
char lower = tolower(str[0]);
hashtable.emplace(lower, 1);
....
1错误C2780:'std::pair std::_Hash::emplace(_Valty&)':需要1个参数-提供2个参数
2 IntelliSense:函数模板“std::tr1::无序_map::emplace[with _Kty=char,_Ty=int,_Hasher=std::hash,_Keyeq=std::equal_to,_Alloc=std::allocator]”的实例与参数列表不匹配

<代码> > p>您使用的是VisualC++的旧版本,它没有正确地支持<代码> ESPOT//C>。大概是Visual C++ 2010。 正如《圣经》所说:

根据C++11的要求,我们实现了 emplace()/emplace\u front()/emplace\u back()/emplace\u hint()/emplace\u after() 在“任意”数量的参数的所有容器中(见下文)

(……)

VC10支持从1个参数定位,但不是 特别有用。


最好的解决方案是升级到编译器的最新版本。

< p>你使用的是一个旧版本的VisualC++,它没有正确地支持<代码> ESPOT/<代码>。大概是Visual C++ 2010。 正如《圣经》所说:

根据C++11的要求,我们实现了 emplace()/emplace\u front()/emplace\u back()/emplace\u hint()/emplace\u after() 在“任意”数量的参数的所有容器中(见下文)

(……)

VC10支持从1个参数定位,但不是 特别有用。


最好的解决方案是升级到编译器的最新版本。

< p>你使用的是一个旧版本的VisualC++,它没有正确地支持<代码> ESPOT/<代码>。大概是Visual C++ 2010。 正如《圣经》所说:

根据C++11的要求,我们实现了 emplace()/emplace\u front()/emplace\u back()/emplace\u hint()/emplace\u after() 在“任意”数量的参数的所有容器中(见下文)

(……)

VC10支持从1个参数定位,但不是 特别有用。


最好的解决方案是升级到编译器的最新版本。

< p>你使用的是一个旧版本的VisualC++,它没有正确地支持<代码> ESPOT/<代码>。大概是Visual C++ 2010。 正如《圣经》所说:

根据C++11的要求,我们实现了 emplace()/emplace\u front()/emplace\u back()/emplace\u hint()/emplace\u after() 在“任意”数量的参数的所有容器中(见下文)

(……)

VC10支持从1个参数定位,但不是 特别有用。


最好的解决方案是升级到编译器的最新版本。

以下是一些可以解决问题的扩展

1   error C2780: 'std::pair<_Ty1,_Ty2> std::_Hash<_Traits>::emplace(_Valty &&)' : expects 1 arguments - 2 provided  
2   IntelliSense: no instance of function template "std::tr1::unordered_map<_Kty, _Ty, _Hasher, _Keyeq, _Alloc>::emplace [with _Kty=char, _Ty=int, _Hasher=std::hash<char>, _Keyeq=std::equal_to<char>, _Alloc=std::allocator<std::pair<const char, int>>]" matches the argument list
#包含//用于std::pair
std::无序的_映射哈希表;
char lower='A';
hashtable.emplace(std::pair(lower,1));

如果粘贴的代码编译似乎取决于基础编译器。放置std::pair的处理适用于例如c++11——根据规范(例如),您的代码段应该适用于c++14。

以下一些扩展可以解决您的问题

1   error C2780: 'std::pair<_Ty1,_Ty2> std::_Hash<_Traits>::emplace(_Valty &&)' : expects 1 arguments - 2 provided  
2   IntelliSense: no instance of function template "std::tr1::unordered_map<_Kty, _Ty, _Hasher, _Keyeq, _Alloc>::emplace [with _Kty=char, _Ty=int, _Hasher=std::hash<char>, _Keyeq=std::equal_to<char>, _Alloc=std::allocator<std::pair<const char, int>>]" matches the argument list
#包含//用于std::pair
std::无序的_映射哈希表;
char lower='A';
hashtable.emplace(std::pair(lower,1));

如果粘贴的代码编译似乎取决于基础编译器。放置std::pair的处理适用于例如c++11——根据规范(例如),您的代码段应该适用于c++14。

以下一些扩展可以解决您的问题

1   error C2780: 'std::pair<_Ty1,_Ty2> std::_Hash<_Traits>::emplace(_Valty &&)' : expects 1 arguments - 2 provided  
2   IntelliSense: no instance of function template "std::tr1::unordered_map<_Kty, _Ty, _Hasher, _Keyeq, _Alloc>::emplace [with _Kty=char, _Ty=int, _Hasher=std::hash<char>, _Keyeq=std::equal_to<char>, _Alloc=std::allocator<std::pair<const char, int>>]" matches the argument list
#包含//用于std::pair
std::无序的_映射哈希表;
char lower='A';
hashtable.emplace(std::pair(lower,1));

如果粘贴的代码编译似乎取决于基础编译器。放置std::pair的处理适用于例如c++11——根据规范(例如),您的代码段应该适用于c++14。

以下一些扩展可以解决您的问题

1   error C2780: 'std::pair<_Ty1,_Ty2> std::_Hash<_Traits>::emplace(_Valty &&)' : expects 1 arguments - 2 provided  
2   IntelliSense: no instance of function template "std::tr1::unordered_map<_Kty, _Ty, _Hasher, _Keyeq, _Alloc>::emplace [with _Kty=char, _Ty=int, _Hasher=std::hash<char>, _Keyeq=std::equal_to<char>, _Alloc=std::allocator<std::pair<const char, int>>]" matches the argument list
#包含//用于std::pair
std::无序的_映射哈希表;
char lower='A';
hashtable.emplace(std::pair(lower,1));

如果粘贴的代码编译似乎取决于基础编译器。安置std::pair的处理适用于例如c++11——根据规范(例如)您的代码段应该与c++14一起使用。

如果它是VS<2013,则它不支持使用多个参数的
emplace
如果它是VS<2013,则它不支持使用多个参数的
emplace
如果它是VS<2013,则它不支持使用多个参数的
emplace
不支持使用多个参数部署
噢,明白了!谢谢:)哦,明白了!谢谢:)哦,明白了!谢谢:)哦,明白了!谢谢:)