我正在尝试在 RHEL 上编译一个非常旧的 cpp 代码,并遇到以下错误。我不确定为什么编译器会用一个值代替分配器?这是什么意思,有人可以指出问题是什么以及解决方案吗?欣赏它。
#include<iostream>
#include <map>
#include <vector>
#include<memory>
#include<string>
using std::map;
using std::string;
using std::vector;
class Clue {
public:
Clue() {std::cout "Clue" << endl;}
};
class Field {
public:
Field() {std::cout "Field" << endl;}
};
class S
{
public:
typedef map<string,Field,std::less<string>, std::allocator> tFieldsList;
typedef map<string ,Field, std::less<string>, std::allocator >::const_iterator
cFieldsIter;
typedef map<string ,Field, std::less<string>, std::allocator >::iterator FieldsIter;
typedef vector<Clue,std::allocator> tVectorClue;
};
int main () {
S s;
return 0;
}
这是我得到的错误:
allocatortypemismathch.C: In constructor âClue::Clue()â:
allocatortypemismathch.C:14: error: expected â;â before string constant
allocatortypemismathch.C: In constructor âField::Field()â:
allocatortypemismathch.C:19: error: expected â;â before string constant
allocatortypemismathch.C: At global scope:
allocatortypemismathch.C:25: error: type/value mismatch at argument 4 in template parameter list for âtemplate<class _Key, class _Tp, class _Compare, class _Alloc> class std::mapâ
allocatortypemismathch.C:25: error: expected a type, got âallocatorâ
allocatortypemismathch.C:26: error: type/value mismatch at argument 4 in template parameter list for âtemplate<class _Key, class _Tp, class _Compare, class _Alloc> class std::mapâ
allocatortypemismathch.C:26: error: expected a type, got âallocatorâ
allocatortypemismathch.C:27: error: expected â;â before âcFieldsIterâ
allocatortypemismathch.C:28: error: type/value mismatch at argument 4 in template parameter list for âtemplate<class _Key, class _Tp, class _Compare, class _Alloc> class std::mapâ
allocatortypemismathch.C:28: error: expected a type, got âallocatorâ
allocatortypemismathch.C:28: error: expected â;â before âFieldsIterâ
allocatortypemismathch.C:29: error: type/value mismatch at argument 2 in template parameter list for âtemplate<class _Tp, class _Alloc> class std::vectorâ
allocatortypemismathch.C:29: error: expected a type, got âallocatorâ