C++ C+中的映射错误+;
我使用的是GCC 4.6编译器,当我构建代码(ns3)时,我得到错误:C++ C+中的映射错误+;,c++,dictionary,build,stl,waf,C++,Dictionary,Build,Stl,Waf,我使用的是GCC 4.6编译器,当我构建代码(ns3)时,我得到错误: In file included from /usr/include/c++/4.4/map:60, from ../src/internet-stack/tcp-typedefs.h:23, from ../src/internet-stack/mp-tcp-socket-impl.cc:16: /usr/include/c++/4.4/bits/stl_
In file included from /usr/include/c++/4.4/map:60,
from ../src/internet-stack/tcp-typedefs.h:23,
from ../src/internet-stack/mp-tcp-socket-impl.cc:16:
/usr/include/c++/4.4/bits/stl_tree.h: In member function ‘void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_II, _II) [with _InputIterator = unsigned int, _Key = unsigned int, _Val = std::pair<const unsigned int, unsigned int>, _KeyOfValue = std::_Select1st<std::pair<const unsigned int, unsigned int> >, _Compare = std::less<unsigned int>, _Alloc = std::allocator<std::pair<const unsigned int, unsigned int> >]’:
/usr/include/c++/4.4/bits/stl_map.h:553: instantiated from ‘void std::map<_Key, _Tp, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = unsigned int, _Key = unsigned int, _Tp = unsigned int, _Compare = std::less<unsigned int>, _Alloc = std::allocator<std::pair<const unsigned int, unsigned int> >]’
../src/internet-stack/mp-tcp-socket-impl.cc:1536: instantiated from here
/usr/include/c++/4.4/bits/stl_tree.h:1324: error: invalid type argument of ‘unary *’
我想不出解决这个问题的办法。谢谢你的帮助 您将GCC4.4中的LIB与GCC4.6一起使用-这可能是问题所在
尝试将4.6头文件传递给编译器(如-I/usr/include/c++/4.6)我认为您没有像预期那样使用insert方法。我不确定,因为我看不到您正在使用的参数声明,但编译器说您正在使用该方法:
void insert (InputIterator first, InputIterator last)
因此,参数可能是同一容器的迭代器。这里,第一个参数指定要复制的容器的开始,最后一个参数标记此范围的结束(不包括最后一个元素)。
以下是您拥有的其他选项:
pair<iterator,bool> insert (const value_type& val);
最后一个与前一个类似,但它告诉地图新元素的位置可能在位置附近。但这只是一个性能提示,因为map是一个具有明确顺序的树
因此,您的代码可能类似于dis.insert(make_pair(p,t))代码>
关于。在保留功能的同时,我可以以任何方式更改代码本身。这个问题与
void insert (InputIterator first, InputIterator last)
pair<iterator,bool> insert (const value_type& val);
iterator insert (iterator position, const value_type& val);