根据http://www.cplusplus.com/reference/vector/vector/operator=/我了解我们可以使用“=”运算符来分配向量。但是运行下面的代码,我得到一个错误。出了什么问题?
代码:
void checkFunction(map<string, vector<string> > foo){
vector<string> bar;
bar = foo.find("ABC");
}
错误 :
error: no match for ‘operator=’ in ‘bar = foo.std::map<_Key, _Tp, _Compare, _Alloc>::find [with _Key = std::basic_string<char>, _Tp = std::vector<std::basic_string<char> >, _Compare = std::less<std::basic_string<char> >, _Alloc = std::allocator<std::pair<const std::basic_string<char>, std::vector<std::basic_string<char> > > >, std::map<_Key, _Tp, _Compare, _Alloc>::iterator = std::_Rb_tree_iterator<std::pair<const std::basic_string<char>, std::vector<std::basic_string<char> > > >, key_type = std::basic_string<char>](((const std::map<std::basic_string<char>, std::vector<std::basic_string<char> > >::key_type&)(& std::basic_string<char>(((const char*)"PAR"), ((const std::allocator<char>&)((const std::allocator<char>*)(& std::allocator<char>())))))))’
std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = std::basic_string<char>, _Alloc = std::allocator<std::basic_string<char> >]
std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = std::basic_string<char>, _Alloc = std::allocator<std::basic_string<char> >, std::vector<_Tp, _Alloc> = std::vector<std::basic_string<char> >]
std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_CharT>) [with _Tp = std::basic_string<char>, _Alloc = std::allocator<std::basic_string<char> >, std::vector<_Tp, _Alloc> = std::vector<std::basic_string<char> >]