fork download
  1. #include <map>
  2. #include <algorithm>
  3.  
  4. struct Compare {
  5. bool operator() (std::pair<std::string, int> l,
  6. std::pair<std::string, int> r) {
  7. return (l.second < r.second);
  8. }
  9. } comp;
  10.  
  11. int main()
  12. {
  13. std::map<std::string, int> errs;
  14.  
  15. std::sort(errs.begin(), errs.end(), comp);
  16. return 0;
  17. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
In file included from /usr/include/c++/4.7/algorithm:63:0,
                 from prog.cpp:2:
/usr/include/c++/4.7/bits/stl_algo.h: In instantiation of ‘void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = std::_Rb_tree_iterator<std::pair<const std::basic_string<char>, int> >; _Compare = Compare]’:
prog.cpp:15:41:   required from here
/usr/include/c++/4.7/bits/stl_algo.h:5514:4: error: no match for ‘operator-’ in ‘__last - __first’
/usr/include/c++/4.7/bits/stl_algo.h:5514:4: note: candidates are:
In file included from /usr/include/c++/4.7/bits/stl_algobase.h:68:0,
                 from /usr/include/c++/4.7/bits/stl_tree.h:63,
                 from /usr/include/c++/4.7/map:60,
                 from prog.cpp:1:
/usr/include/c++/4.7/bits/stl_iterator.h:329:5: note: template<class _Iterator> typename std::reverse_iterator::difference_type std::operator-(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
/usr/include/c++/4.7/bits/stl_iterator.h:329:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/4.7/algorithm:63:0,
                 from prog.cpp:2:
/usr/include/c++/4.7/bits/stl_algo.h:5514:4: note:   ‘std::_Rb_tree_iterator<std::pair<const std::basic_string<char>, int> >’ is not derived from ‘const std::reverse_iterator<_Iterator>’
In file included from /usr/include/c++/4.7/bits/stl_algobase.h:68:0,
                 from /usr/include/c++/4.7/bits/stl_tree.h:63,
                 from /usr/include/c++/4.7/map:60,
                 from prog.cpp:1:
/usr/include/c++/4.7/bits/stl_iterator.h:381:5: note: template<class _IteratorL, class _IteratorR> decltype ((__y.base() - __x.base())) std::operator-(const std::reverse_iterator<_IteratorL>&, const std::reverse_iterator<_IteratorR>&)
/usr/include/c++/4.7/bits/stl_iterator.h:381:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/4.7/algorithm:63:0,
                 from prog.cpp:2:
/usr/include/c++/4.7/bits/stl_algo.h:5514:4: note:   ‘std::_Rb_tree_iterator<std::pair<const std::basic_string<char>, int> >’ is not derived from ‘const std::reverse_iterator<_IteratorL>’
In file included from /usr/include/c++/4.7/bits/stl_algobase.h:68:0,
                 from /usr/include/c++/4.7/bits/stl_tree.h:63,
                 from /usr/include/c++/4.7/map:60,
                 from prog.cpp:1:
/usr/include/c++/4.7/bits/stl_iterator.h:1106:5: note: template<class _IteratorL, class _IteratorR> decltype ((__x.base() - __y.base())) std::operator-(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&)
/usr/include/c++/4.7/bits/stl_iterator.h:1106:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/4.7/algorithm:63:0,
                 from prog.cpp:2:
/usr/include/c++/4.7/bits/stl_algo.h:5514:4: note:   ‘std::_Rb_tree_iterator<std::pair<const std::basic_string<char>, int> >’ is not derived from ‘const std::move_iterator<_IteratorL>’
In file included from /usr/include/c++/4.7/bits/stl_algobase.h:68:0,
                 from /usr/include/c++/4.7/bits/stl_tree.h:63,
                 from /usr/include/c++/4.7/map:60,
                 from prog.cpp:1:
/usr/include/c++/4.7/bits/stl_iterator.h:1113:5: note: template<class _Iterator> decltype ((__x.base() - __y.base())) std::operator-(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&)
/usr/include/c++/4.7/bits/stl_iterator.h:1113:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/4.7/algorithm:63:0,
                 from prog.cpp:2:
/usr/include/c++/4.7/bits/stl_algo.h:5514:4: note:   ‘std::_Rb_tree_iterator<std::pair<const std::basic_string<char>, int> >’ is not derived from ‘const std::move_iterator<_Iterator>’
In file included from /usr/include/c++/4.7/vector:66:0,
                 from /usr/include/c++/4.7/bits/random.h:34,
                 from /usr/include/c++/4.7/random:50,
                 from /usr/include/c++/4.7/bits/stl_algo.h:67,
                 from /usr/include/c++/4.7/algorithm:63,
                 from prog.cpp:2:
/usr/include/c++/4.7/bits/stl_bvector.h:183:3: note: std::ptrdiff_t std::operator-(const std::_Bit_iterator_base&, const std::_Bit_iterator_base&)
/usr/include/c++/4.7/bits/stl_bvector.h:183:3: note:   no known conversion for argument 1 from ‘std::_Rb_tree_iterator<std::pair<const std::basic_string<char>, int> >’ to ‘const std::_Bit_iterator_base&’
In file included from /usr/include/c++/4.7/bits/stl_algobase.h:68:0,
                 from /usr/include/c++/4.7/bits/stl_tree.h:63,
                 from /usr/include/c++/4.7/map:60,
                 from prog.cpp:1:
/usr/include/c++/4.7/bits/stl_iterator.h:898:5: note: template<class _Iterator, class _Container> typename __gnu_cxx::__normal_iterator::difference_type __gnu_cxx::operator-(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)
/usr/include/c++/4.7/bits/stl_iterator.h:898:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/4.7/algorithm:63:0,
                 from prog.cpp:2:
/usr/include/c++/4.7/bits/stl_algo.h:5514:4: note:   ‘std::_Rb_tree_iterator<std::pair<const std::basic_string<char>, int> >’ is not derived from ‘const __gnu_cxx::__normal_iterator<_Iterator, _Container>’
In file included from /usr/include/c++/4.7/bits/stl_algobase.h:68:0,
                 from /usr/include/c++/4.7/bits/stl_tree.h:63,
                 from /usr/include/c++/4.7/map:60,
                 from prog.cpp:1:
/usr/include/c++/4.7/bits/stl_iterator.h:886:5: note: template<class _IteratorL, class _IteratorR, class _Container> decltype ((__lhs.base() - __rhs.base())) __gnu_cxx::operator-(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)
/usr/include/c++/4.7/bits/stl_iterator.h:886:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/4.7/algorithm:63:0,
                 from prog.cpp:2:
/usr/include/c++/4.7/bits/stl_algo.h:5514:4: note:   ‘std::_Rb_tree_iterator<std::pair<const std::basic_string<char>, int> >’ is not derived from ‘const __gnu_cxx::__normal_iterator<_IteratorL, _Container>’
stdout
Standard output is empty