博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
std::map使用结构体自定义键值
阅读量:5227 次
发布时间:2019-06-14

本文共 23050 字,大约阅读时间需要 76 分钟。

使用STL中的map时候,有时候需要使用结构题自定义键值,比如想统计点的坐标出现的次数

struct Node{    int x,y;};......map
mp;mp[(Node){x,y}]++;

  这样子的话,会出现一堆报错

c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h||In instantiation of 'bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = Node]':|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_map.h|483|required from 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = Node; _Tp = int; _Compare = std::less
; _Alloc = std::allocator
>; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = Node]'|E:\Programming Design\practice\ceshi.cpp|27|required from here|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|error: no match for 'operator<' (operand types are 'const Node' and 'const Node')|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: candidates are:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_pair.h|220|note: template
constexpr bool std::operator<(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_pair.h|220|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::pair<_T1, _T2>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_iterator.h|297|note: template
bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_iterator.h|297|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::reverse_iterator<_Iterator>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_iterator.h|347|note: template
bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_iterator.h|347|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::reverse_iterator<_Iterator>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_iterator.h|1055|note: template
bool std::operator<(const std::move_iterator<_Iterator>&, const std::move_iterator<_IteratorR>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_iterator.h|1055|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::move_iterator<_Iterator>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_iterator.h|1061|note: template
bool std::operator<(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_iterator.h|1061|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::move_iterator<_Iterator>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\basic_string.h|2569|note: template
bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\basic_string.h|2569|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\basic_string.h|2581|note: template
bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\basic_string.h|2581|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\basic_string.h|2593|note: template
bool std::operator<(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\basic_string.h|2593|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: mismatched types 'const _CharT*' and 'Node'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_vector.h|1420|note: template
bool std::operator<(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_vector.h|1420|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::vector<_Tp, _Alloc>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array|238|note: template
bool std::operator<(const std::array<_Tp, _Nm>&, const std::array<_Tp, _Nm>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array|238|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::array<_Tp, _Nm>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\tuple|822|note: template
constexpr bool std::operator<(const std::tuple<_Elements ...>&, const std::tuple<_Elements ...>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\tuple|822|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::tuple<_Elements ...>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_deque.h|273|note: template
bool std::operator<(const std::_Deque_iterator<_Tp, _Ref, _Ptr>&, const std::_Deque_iterator<_Tp, _Ref, _Ptr>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_deque.h|273|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::_Deque_iterator<_Tp, _Ref, _Ptr>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_deque.h|281|note: template
bool std::operator<(const std::_Deque_iterator<_Tp, _Ref, _Ptr>&, const std::_Deque_iterator<_Tp, _RefR, _PtrR>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_deque.h|281|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::_Deque_iterator<_Tp, _Ref, _Ptr>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_deque.h|1975|note: template
bool std::operator<(const std::deque<_Tp, _Alloc>&, const std::deque<_Tp, _Alloc>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_deque.h|1975|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::deque<_Tp, _Alloc>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_list.h|1631|note: template
bool std::operator<(const std::list<_Tp, _Alloc>&, const std::list<_Tp, _Alloc>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_list.h|1631|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::list<_Tp, _Alloc>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_tree.h|914|note: template
bool std::operator<(const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_tree.h|914|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_map.h|978|note: template
bool std::operator<(const std::map<_Key, _Tp, _Compare, _Alloc>&, const std::map<_Key, _Tp, _Compare, _Alloc>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_map.h|978|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::map<_Key, _Tp, _Compare, _Alloc>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_multimap.h|880|note: template
bool std::operator<(const std::multimap<_Key, _Tp, _Compare, _Alloc>&, const std::multimap<_Key, _Tp, _Compare, _Alloc>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_multimap.h|880|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::multimap<_Key, _Tp, _Compare, _Alloc>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\unique_ptr.h|523|note: template
bool std::operator<(const std::unique_ptr<_Tp, _Dp>&, const std::unique_ptr<_Up, _Ep>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\unique_ptr.h|523|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::unique_ptr<_Tp, _Dp>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\unique_ptr.h|534|note: template
bool std::operator<(const std::unique_ptr<_Tp, _Dp>&, std::nullptr_t)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\unique_ptr.h|534|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::unique_ptr<_Tp, _Dp>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\unique_ptr.h|540|note: template
bool std::operator<(std::nullptr_t, const std::unique_ptr<_Tp, _Dp>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\unique_ptr.h|540|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: cannot convert '__x' (type 'const Node') to type 'std::nullptr_t'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\shared_ptr_base.h|1090|note: template
bool std::operator<(const std::__shared_ptr<_Tp1, _Lp>&, const std::__shared_ptr<_Tp2, _Lp>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\shared_ptr_base.h|1090|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::__shared_ptr<_Tp1, _Lp>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\shared_ptr_base.h|1099|note: template
bool std::operator<(const std::__shared_ptr<_Tp, _Lp>&, std::nullptr_t)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\shared_ptr_base.h|1099|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::__shared_ptr<_Tp, _Lp>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\shared_ptr_base.h|1104|note: template
bool std::operator<(std::nullptr_t, const std::__shared_ptr<_Tp, _Lp>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\shared_ptr_base.h|1104|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: cannot convert '__x' (type 'const Node') to type 'std::nullptr_t'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\shared_ptr.h|359|note: template
bool std::operator<(const std::shared_ptr<_Tp1>&, const std::shared_ptr<_Tp2>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\shared_ptr.h|359|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::shared_ptr<_Tp1>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\shared_ptr.h|368|note: template
bool std::operator<(const std::shared_ptr<_Tp1>&, std::nullptr_t)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\shared_ptr.h|368|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::shared_ptr<_Tp1>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\shared_ptr.h|373|note: template
bool std::operator<(std::nullptr_t, const std::shared_ptr<_Tp1>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\shared_ptr.h|373|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: cannot convert '__x' (type 'const Node') to type 'std::nullptr_t'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_queue.h|286|note: template
bool std::operator<(const std::queue<_Tp, _Seq>&, const std::queue<_Tp, _Seq>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_queue.h|286|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::queue<_Tp, _Seq>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_set.h|769|note: template
bool std::operator<(const std::set<_Key, _Compare, _Alloc>&, const std::set<_Key, _Compare, _Alloc>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_set.h|769|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::set<_Key, _Compare, _Alloc>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_multiset.h|754|note: template
bool std::operator<(const std::multiset<_Key, _Compare, _Alloc>&, const std::multiset<_Key, _Compare, _Alloc>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_multiset.h|754|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::multiset<_Key, _Compare, _Alloc>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_stack.h|261|note: template
bool std::operator<(const std::stack<_Tp, _Seq>&, const std::stack<_Tp, _Seq>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_stack.h|261|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::stack<_Tp, _Seq>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\valarray_after.h|416|note: template
std::_Expr
, typename std::__fun
::result_type> std::operator<(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::_Expr<_Dom2, typename _Dom2::value_type>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\valarray_after.h|416|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\valarray_after.h|416|note: template
std::_Expr
, typename std::__fun
::result_type> std::operator<(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\valarray_after.h|416|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\valarray_after.h|416|note: template
std::_Expr
, typename std::__fun
::result_type> std::operator<(const typename _Dom::value_type&, const std::_Expr<_Dom1, typename _Dom1::value_type>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\valarray_after.h|416|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\valarray_after.h|416|note: template
std::_Expr
, typename std::__fun
::result_type> std::operator<(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::valarray
&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\valarray_after.h|416|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\valarray_after.h|416|note: template
std::_Expr
, typename std::__fun
::result_type> std::operator<(const std::valarray
&, const std::_Expr<_Dom1, typename _Dom1::value_type>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\valarray_after.h|416|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::valarray
'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\valarray|1168|note: template
std::_Expr
, typename std::__fun
::result_type> std::operator<(const std::valarray<_Tp>&, const std::valarray<_Tp>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\valarray|1168|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::valarray<_Tp>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\valarray|1168|note: template
std::_Expr
, typename std::__fun
::result_type> std::operator<(const std::valarray<_Tp>&, const _Tp&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\valarray|1168|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::valarray<_Tp>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\valarray|1168|note: template
std::_Expr
, typename std::__fun
::result_type> std::operator<(const _Tp&, const std::valarray<_Tp>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\valarray|1168|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::valarray<_Tp>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\system_error|177|note: bool std::operator<(const std::error_code&, const std::error_code&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\system_error|177|note: no known conversion for argument 1 from 'const Node' to 'const std::error_code&'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\system_error|250|note: bool std::operator<(const std::error_condition&, const std::error_condition&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\system_error|250|note: no known conversion for argument 1 from 'const Node' to 'const std::error_condition&'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\forward_list.h|1359|note: template
bool std::operator<(const std::forward_list<_Tp, _Alloc>&, const std::forward_list<_Tp, _Alloc>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\forward_list.h|1359|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::forward_list<_Tp, _Alloc>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\regex.h|879|note: template
bool std::operator<(const std::sub_match<_BiIter>&, const std::sub_match<_BiIter>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\regex.h|879|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::sub_match<_BiIter>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\regex.h|955|note: template
bool std::operator<(std::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const std::sub_match<_BiIter>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\regex.h|955|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'std::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\regex.h|1029|note: template
bool std::operator<(const std::sub_match<_BiIter>&, std::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\regex.h|1029|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::sub_match<_BiIter>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\regex.h|1103|note: template
bool std::operator<(const typename std::iterator_traits<_Iter>::value_type*, const std::sub_match<_BiIter>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\regex.h|1103|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: mismatched types 'const typename std::iterator_traits<_Iter>::value_type*' and 'Node'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\regex.h|1177|note: template
bool std::operator<(const std::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\regex.h|1177|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::sub_match<_BiIter>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\regex.h|1254|note: template
bool std::operator<(const typename std::iterator_traits<_Iter>::value_type&, const std::sub_match<_BiIter>&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\regex.h|1254|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::sub_match<_BiIter>'|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\regex.h|1334|note: template
bool std::operator<(const std::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\regex.h|1334|note: template argument deduction/substitution failed:|c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_function.h|235|note: 'const Node' is not derived from 'const std::sub_match<_BiIter>'|||=== Build failed: 1 error(s), 3 warning(s) (0 minute(s), 4 second(s)) ===|

  看着似乎满屏错误,其实就是少了一个键值比较函数,因为我们知道map插入键值后默认从小到大排序,使用自定义结构体作为键值,但是没有自定义比较函数的话,编译器无法为插入的元素排序。

struct Node{    int x,y;    bool operator < (const Node &a)const    {        if (x == a.x)   return y < a.y;        else return x < a.x;    }};

  这样子修改后,就可以成功运行了。其实从这个例子,我们可以类比用结构体自定义优先队列,也是需要自写比较函数的。

转载于:https://www.cnblogs.com/ZhaoxiCheung/p/6790718.html

你可能感兴趣的文章
再谈Vmware NAT的配置和路由流程
查看>>
javaScript数组去重方法汇总
查看>>
评价意见整合
查看>>
二、create-react-app自定义配置
查看>>
Android PullToRefreshExpandableListView的点击事件
查看>>
系统的横向结构(AOP)
查看>>
linux常用命令
查看>>
NHibernate.3.0.Cookbook第四章第6节的翻译
查看>>
例1-1
查看>>
马达调速器,直流马达调速器,直流调速器
查看>>
前端编码规范小记
查看>>
c如何弹出保存路径/保存文件对话框
查看>>
HTML标签二
查看>>
Python 3语法小记(九) 异常 Exception
查看>>
使用shared memory 计算矩阵乘法 (其实并没有加速多少)
查看>>
Django 相关
查看>>
git init
查看>>
训练记录
查看>>
IList和DataSet性能差别 转自 http://blog.csdn.net/ilovemsdn/article/details/2954335
查看>>
Hive教程(1)
查看>>