fork(1) download
  1. #include <set>
  2. #include <stdio.h>
  3.  
  4. int main() {
  5. std::set<int> x = {1,2,3,4};
  6. printf("%d", x.end() - x.begin())
  7. return 0;
  8. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:6:36: error: no match for ‘operator-’ in ‘x.std::set<_Key, _Compare, _Alloc>::end<int, std::less<int>, std::allocator<int> >() - x.std::set<_Key, _Compare, _Alloc>::begin<int, std::less<int>, std::allocator<int> >()’
prog.cpp:6:36: 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/set: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:
prog.cpp:6:36: note:   ‘std::set<int>::iterator {aka std::_Rb_tree_const_iterator<int>}’ is not derived from ‘const std::move_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/set: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:
prog.cpp:6:36: note:   ‘std::set<int>::iterator {aka std::_Rb_tree_const_iterator<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/set: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:
prog.cpp:6:36: note:   ‘std::set<int>::iterator {aka std::_Rb_tree_const_iterator<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/set: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:
prog.cpp:6:36: note:   ‘std::set<int>::iterator {aka std::_Rb_tree_const_iterator<int>}’ is not derived from ‘const std::reverse_iterator<_Iterator>’
prog.cpp:7:5: error: expected ‘;’ before ‘return’
stdout
Standard output is empty