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

struct Node{
int x,y;
}; ...... map<Node,int>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<Node>; _Alloc = std::allocator<std::pair<const Node, int> >; 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<class _T1, class _T2> 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<class _Iterator> 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<class _IteratorL, class _IteratorR> 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<class _IteratorL, class _IteratorR> 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<class _Iterator> 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<class _CharT, class _Traits, class _Alloc> 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<class _CharT, class _Traits, class _Alloc> 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<class _CharT, class _Traits, class _Alloc> 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<class _Tp, class _Alloc> 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<class _Tp, unsigned int _Nm> 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<class ... _TElements, class ... _UElements> 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<class _Tp, class _Ref, class _Ptr> 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<class _Tp, class _RefL, class _PtrL, class _RefR, class _PtrR> 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<class _Tp, class _Alloc> 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<class _Tp, class _Alloc> 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<class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc> 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<class _Key, class _Tp, class _Compare, class _Alloc> 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<class _Key, class _Tp, class _Compare, class _Alloc> 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<class _Tp, class _Dp, class _Up, class _Ep> 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<class _Tp, class _Dp> 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<class _Tp, class _Dp> 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<class _Tp1, class _Tp2, __gnu_cxx::_Lock_policy _Lp> 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<class _Tp, __gnu_cxx::_Lock_policy _Lp> 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<class _Tp, __gnu_cxx::_Lock_policy _Lp> 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<class _Tp1, class _Tp2> 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<class _Tp> 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<class _Tp> 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<class _Tp, class _Seq> 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<class _Key, class _Compare, class _Alloc> 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<class _Key, class _Compare, class _Alloc> 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<class _Tp, class _Seq> 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<class _Dom1, class _Dom2> std::_Expr<std::_BinClos<std::__less, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__less, typename _Dom1::value_type>::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<class _Dom> std::_Expr<std::_BinClos<std::__less, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__less, typename _Dom1::value_type>::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<class _Dom> std::_Expr<std::_BinClos<std::__less, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__less, typename _Dom1::value_type>::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<class _Dom> std::_Expr<std::_BinClos<std::__less, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__less, typename _Dom1::value_type>::result_type> std::operator<(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::valarray<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<class _Dom> std::_Expr<std::_BinClos<std::__less, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__less, typename _Dom1::value_type>::result_type> std::operator<(const std::valarray<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::valarray<typename _Dom::value_type>'|
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\valarray|1168|note: template<class _Tp> std::_Expr<std::_BinClos<std::__less, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__less, _Tp>::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<class _Tp> std::_Expr<std::_BinClos<std::__less, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__less, _Tp>::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<class _Tp> std::_Expr<std::_BinClos<std::__less, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__less, _Tp>::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<class _Tp, class _Alloc> 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<class _BiIter> 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<class _Bi_iter, class _Ch_traits, class _Ch_alloc> 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<class _Bi_iter, class _Ch_traits, class _Ch_alloc> 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<class _Bi_iter> 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<class _Bi_iter> 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<class _Bi_iter> 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<class _Bi_iter> 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;
}
};

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

std::map使用结构体自定义键值的更多相关文章

  1. map自定义键值类型

    map自定义键值类型 改变Map的默认比较方式 https://www.cnblogs.com/zjfdlut/archive/2011/08/12/2135698.html 大家知道,STL中的ma ...

  2. STL: unordered_map 自定义键值使用

    使用Windows下 RECT 类型做unordered_map 键值 1. Hash 函数 计算自定义类型的hash值. struct hash_RECT { size_t operator()(c ...

  3. Android下添加新的自定义键值和按键处理流程【转】

    本文转载自: Android下添加新的自定义键值和按键处理流程     说出来不怕大家笑话,我写这篇博客的原因在于前几天去一个小公司面试Android系统工程师,然后在面试的时候对方的技术总监问了我一 ...

  4. Android下添加新的自定义键值和按键处理流程

            Android下添加新的自定义键值和按键处理流程     说出来不怕大家笑话,我写这篇博客的原因在于前几天去一个小公司面试Android系统工程师,然后在面试的时候对方的技术总监问了我 ...

  5. Android(java)学习笔记105:Map集合的遍历之键值对对象找键和值

    package cn.itcast_01; import java.util.HashMap; import java.util.Map; import java.util.Set; /* * Map ...

  6. Android(java)学习笔记44:Map集合的遍历之键值对对象找键和值

    1. Map集合的遍历之 键值对对象找 键和值: package cn.itcast_01; import java.util.HashMap; import java.util.Map; impor ...

  7. go 数组(array)、切片(slice)、map、结构体(struct)

    一 数组(array) go语言中的数组是固定长度的.使用前必须指定数组长度. go语言中数组是值类型.如果将数组赋值给另一个数组或者方法中参数使用都是复制一份,方法中使用可以使用指针传递地址. 声明 ...

  8. QT: QByteArray储存二进制数据(包括结构体,自定义QT对象)

      因为利用QByteArray可以很方便的利用其API对内存数据进行访问和修改, 构建数据库blob字段时必不可少; 那如何向blob内写入自定义的结构体和类 1. 利用memcpy拷贝内存数据 / ...

  9. map中结构体做关键字的注意事项

    序: 今天做一道题,由于递归函数比较恶心,如果用记忆化搜索,数据范围极大却又用不全(二维数组存的话直接炸).所以决定干脆使用stl::map存储(反正有O2优化),但是执行insert的时候,编译器却 ...

随机推荐

  1. Jquery中$(function(){})

    1. 在哪书写js文件 如果我们要执行一段js代码,我们该怎么办呢? 1.我们可以写一个js文件,在js文件里写执行函数,然后再<script src='...'> ... </sc ...

  2. 本地部署 Misago Docker + 配置 HTTPS 笔记

    最近答应帮朋友做个论坛网站,想借此机会捡起 Python 在 GitHub 找了一圈,打算借用以 Python+Django 开发的 Misago 这个论坛系统 由于作者在今年更新的 Misago 0 ...

  3. React项目 - 几种CSS实践

    前言团队在使用react时,不断探索,使用了很多不同的css实现方式,此篇blog总结了,react项目中常见的几种css解决方案:inline-style/radium/style-componen ...

  4. Python学习第四十一天函数装饰器传参数的用法

    在不改变函数的结构的基础,我们给函数加新的功能,用是函数装饰器,如果要给函数传递参数,那么应该怎么做呢 @timerdef test2(name,age): time.sleep(3) print(' ...

  5. javascript Math取整&获取随机数

    1.方法介绍 Math.ceil(n) 上取整,大于等于n返回与它最接近的整数 Math.floor(n) 下取整,小于等于n返回与它最接近的整数 Math.round(n) 四舍五入取整 Math. ...

  6. Sql在Group by的select中包含多列

    SELECT A , B , COUNT(Id) AS '数量' FROM dbo.[Table] GROUP BY A , B

  7. kali Linux 入门(二)

    九.软件安装 1.apt install --软件名称-- -y 2.apt install packge_name----库安装 3.apt install kali-linux-all -y--- ...

  8. 11JSP基础

    1.Jsp基础 1.1 简介 Jsp,全称 Java Server Page java服务页面,能提供java服务的页面 jsp vs html html: 由html标签组成的,输出静态内容. js ...

  9. Redis分布式锁【实战】

    概述 目前几乎很多大型网站及应用都是分布式部署的,分布式场景中的数据一致性问题一直是一个比较重要的话题.分布式的CAP理论告诉我们“任何一个分布式系统都无法同时满足一致性(Consistency).可 ...

  10. springboot+UEditor图片上传

    springboot+UEDitor百度编辑器整合图片上记录于此 1.下载ueditor插件包,解压到static/ueditor目录下 2.在你所需实现编辑器的页面引用三个JS文件 1)  uedi ...