我想插入一個載體爲一組這樣的:插入對象爲一組
set<vector<prmEdge> > cammini;
vector<prmEdge> vecEdge;
cammini.insert(vecEdge);
我有這樣的編譯錯誤:
prmPlanner.cpp:1285: instantiated from here
/usr/include/c++/4.2/bits/stl_algobase.h:853: error: no match for ‘operator<’ in ‘__first1.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with _Iterator = const prmEdge*, _Container = std::vector<prmEdge, std::allocator<prmEdge> >]() < __first2.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with _Iterator = const prmEdge*, _Container = std::vector<prmEdge, std::allocator<prmEdge> >]()’
/usr/include/c++/4.2/bits/stl_algobase.h:855: error: no match for ‘operator<’ in ‘__first2.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with _Iterator = const prmEdge*, _Container = std::vector<prmEdge, std::allocator<prmEdge> >]() < __first1.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with _Iterator = const prmEdge*, _Container = std::vector<prmEdge, std::allocator<prmEdge> >]()’
make[1]: *** [prmPlanner.o] Errore 1
我應該怎麼辦? 有人能幫助我嗎?
非常感謝你
但有一個非成員操作符<()定義爲vector:http://stdcxx.apache.org/doc/stdlibref/vector.html#idx1350。不應該那樣工作? –
如何用unordered_set聲明一個集合? – livio8495
@Fred Larson,它使用'std :: lexicographical_compare'進行比較,所以應該爲'prmEdge'定義'operator <'。 –