fork(2) download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <cctype>
  5. #include <cstdlib>
  6. #include <fstream>
  7. #include <sstream>
  8. #include <list>
  9. #include <deque>
  10.  
  11.  
  12. int main()
  13. {
  14. std::list<int> nums = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  15.  
  16. auto it = nums.begin();
  17. auto mid = nums.begin() + nums.size() / 2;
  18. while (it != mid)
  19. if (*it == 3)
  20. nums.insert (it, 6);
  21. for (auto &i : nums)
  22. std::cout << i << std::endl;
  23. }
  24.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:17:33: error: no match for 'operator+' (operand types are 'std::list<int>::iterator {aka std::_List_iterator<int>}' and 'std::list<int>::size_type {aka unsigned int}')
         auto mid = nums.begin() + nums.size() / 2;
                                 ^
In file included from /usr/include/c++/5/deque:64:0,
                 from prog.cpp:9:
/usr/include/c++/5/bits/stl_deque.h:372:5: note: candidate: template<class _Tp, class _Ref, class _Ptr> std::_Deque_iterator<_Tp, _Ref, _Ptr> std::operator+(std::ptrdiff_t, const std::_Deque_iterator<_Tp, _Ref, _Ptr>&)
     operator+(ptrdiff_t __n, const _Deque_iterator<_Tp, _Ref, _Ptr>& __x)
     ^
/usr/include/c++/5/bits/stl_deque.h:372:5: note:   template argument deduction/substitution failed:
prog.cpp:17:30: note:   cannot convert 'nums.std::list<_Tp, _Alloc>::begin<int, std::allocator<int> >()' (type 'std::list<int>::iterator {aka std::_List_iterator<int>}') to type 'std::ptrdiff_t {aka int}'
         auto mid = nums.begin() + nums.size() / 2;
                              ^
In file included from /usr/include/c++/5/vector:65:0,
                 from prog.cpp:3:
/usr/include/c++/5/bits/stl_bvector.h:387:3: note: candidate: std::_Bit_const_iterator std::operator+(std::ptrdiff_t, const std::_Bit_const_iterator&)
   operator+(ptrdiff_t __n, const _Bit_const_iterator& __x)
   ^
/usr/include/c++/5/bits/stl_bvector.h:387:3: note:   no known conversion for argument 1 from 'std::list<int>::iterator {aka std::_List_iterator<int>}' to 'std::ptrdiff_t {aka int}'
/usr/include/c++/5/bits/stl_bvector.h:297:3: note: candidate: std::_Bit_iterator std::operator+(std::ptrdiff_t, const std::_Bit_iterator&)
   operator+(ptrdiff_t __n, const _Bit_iterator& __x)
   ^
/usr/include/c++/5/bits/stl_bvector.h:297:3: note:   no known conversion for argument 1 from 'std::list<int>::iterator {aka std::_List_iterator<int>}' to 'std::ptrdiff_t {aka int}'
In file included from /usr/include/c++/5/string:52:0,
                 from /usr/include/c++/5/bits/locale_classes.h:40,
                 from /usr/include/c++/5/bits/ios_base.h:41,
                 from /usr/include/c++/5/ios:42,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/5/bits/basic_string.h:4888:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::basic_string<_CharT, _Traits, _Alloc>&&, _CharT)
     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
     ^
/usr/include/c++/5/bits/basic_string.h:4888:5: note:   template argument deduction/substitution failed:
prog.cpp:17:49: note:   'std::list<int>::iterator {aka std::_List_iterator<int>}' is not derived from 'std::basic_string<_CharT, _Traits, _Alloc>'
         auto mid = nums.begin() + nums.size() / 2;
                                                 ^
In file included from /usr/include/c++/5/string:52:0,
                 from /usr/include/c++/5/bits/locale_classes.h:40,
                 from /usr/include/c++/5/bits/ios_base.h:41,
                 from /usr/include/c++/5/ios:42,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/5/bits/basic_string.h:4882:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::basic_string<_CharT, _Traits, _Alloc>&&, const _CharT*)
     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
     ^
/usr/include/c++/5/bits/basic_string.h:4882:5: note:   template argument deduction/substitution failed:
prog.cpp:17:49: note:   'std::list<int>::iterator {aka std::_List_iterator<int>}' is not derived from 'std::basic_string<_CharT, _Traits, _Alloc>'
         auto mid = nums.begin() + nums.size() / 2;
                                                 ^
In file included from /usr/include/c++/5/string:52:0,
                 from /usr/include/c++/5/bits/locale_classes.h:40,
                 from /usr/include/c++/5/bits/ios_base.h:41,
                 from /usr/include/c++/5/ios:42,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/5/bits/basic_string.h:4876:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, std::basic_string<_CharT, _Traits, _Alloc>&&)
     operator+(_CharT __lhs,
     ^
/usr/include/c++/5/bits/basic_string.h:4876:5: note:   template argument deduction/substitution failed:
prog.cpp:17:49: note:   mismatched types 'std::basic_string<_CharT, _Traits, _Alloc>' and 'std::list<int>::size_type {aka unsigned int}'
         auto mid = nums.begin() + nums.size() / 2;
                                                 ^
In file included from /usr/include/c++/5/string:52:0,
                 from /usr/include/c++/5/bits/locale_classes.h:40,
                 from /usr/include/c++/5/bits/ios_base.h:41,
                 from /usr/include/c++/5/ios:42,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/5/bits/basic_string.h:4870:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, std::basic_string<_CharT, _Traits, _Alloc>&&)
     operator+(const _CharT* __lhs,
     ^
/usr/include/c++/5/bits/basic_string.h:4870:5: note:   template argument deduction/substitution failed:
prog.cpp:17:49: note:   mismatched types 'const _CharT*' and 'std::_List_iterator<int>'
         auto mid = nums.begin() + nums.size() / 2;
                                                 ^
In file included from /usr/include/c++/5/string:52:0,
                 from /usr/include/c++/5/bits/locale_classes.h:40,
                 from /usr/include/c++/5/bits/ios_base.h:41,
                 from /usr/include/c++/5/ios:42,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/5/bits/basic_string.h:4858:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::basic_string<_CharT, _Traits, _Alloc>&&, std::basic_string<_CharT, _Traits, _Alloc>&&)
     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
     ^
/usr/include/c++/5/bits/basic_string.h:4858:5: note:   template argument deduction/substitution failed:
prog.cpp:17:49: note:   'std::list<int>::iterator {aka std::_List_iterator<int>}' is not derived from 'std::basic_string<_CharT, _Traits, _Alloc>'
         auto mid = nums.begin() + nums.size() / 2;
                                                 ^
In file included from /usr/include/c++/5/string:52:0,
                 from /usr/include/c++/5/bits/locale_classes.h:40,
                 from /usr/include/c++/5/bits/ios_base.h:41,
                 from /usr/include/c++/5/ios:42,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/5/bits/basic_string.h:4852:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, std::basic_string<_CharT, _Traits, _Alloc>&&)
     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
     ^
/usr/include/c++/5/bits/basic_string.h:4852:5: note:   template argument deduction/substitution failed:
prog.cpp:17:49: note:   'std::list<int>::iterator {aka std::_List_iterator<int>}' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'
         auto mid = nums.begin() + nums.size() / 2;
                                                 ^
In file included from /usr/include/c++/5/string:52:0,
                 from /usr/include/c++/5/bits/locale_classes.h:40,
                 from /usr/include/c++/5/bits/ios_base.h:41,
                 from /usr/include/c++/5/ios:42,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/5/bits/basic_string.h:4846:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::basic_string<_CharT, _Traits, _Alloc>&&, const std::basic_string<_CharT, _Traits, _Alloc>&)
     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
     ^
/usr/include/c++/5/bits/basic_string.h:4846:5: note:   template argument deduction/substitution failed:
prog.cpp:17:49: note:   'std::list<int>::iterator {aka std::_List_iterator<int>}' is not derived from 'std::basic_string<_CharT, _Traits, _Alloc>'
         auto mid = nums.begin() + nums.size() / 2;
                                                 ^
In file included from /usr/include/c++/5/string:52:0,
                 from /usr/include/c++/5/bits/locale_classes.h:40,
                 from /usr/include/c++/5/bits/ios_base.h:41,
                 from /usr/include/c++/5/ios:42,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/5/bits/basic_string.h:4834:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, _CharT)
     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
     ^
/usr/include/c++/5/bits/basic_string.h:4834:5: note:   template argument deduction/substitution failed:
prog.cpp:17:49: note:   'std::list<int>::iterator {aka std::_List_iterator<int>}' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'
         auto mid = nums.begin() + nums.size() / 2;
                                                 ^
In file included from /usr/include/c++/5/string:52:0,
                 from /usr/include/c++/5/bits/locale_classes.h:40,
                 from /usr/include/c++/5/bits/ios_base.h:41,
                 from /usr/include/c++/5/ios:42,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/5/bits/basic_string.h:4818:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
     ^
/usr/include/c++/5/bits/basic_string.h:4818:5: note:   template argument deduction/substitution failed:
prog.cpp:17:49: note:   'std::list<int>::iterator {aka std::_List_iterator<int>}' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'
         auto mid = nums.begin() + nums.size() / 2;
                                                 ^
In file included from /usr/include/c++/5/string:53:0,
                 from /usr/include/c++/5/bits/locale_classes.h:40,
                 from /usr/include/c++/5/bits/ios_base.h:41,
                 from /usr/include/c++/5/ios:42,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/5/bits/basic_string.tcc:1167:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, const std::basic_string<_CharT, _Traits, _Alloc>&)
     operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs)
     ^
/usr/include/c++/5/bits/basic_string.tcc:1167:5: note:   template argument deduction/substitution failed:
prog.cpp:17:49: note:   mismatched types 'const std::basic_string<_CharT, _Traits, _Alloc>' and 'std::list<int>::size_type {aka unsigned int}'
         auto mid = nums.begin() + nums.size() / 2;
                                                 ^
In file included from /usr/include/c++/5/string:53:0,
                 from /usr/include/c++/5/bits/locale_classes.h:40,
                 from /usr/include/c++/5/bits/ios_base.h:41,
                 from /usr/include/c++/5/ios:42,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/5/bits/basic_string.tcc:1151:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
     operator+(const _CharT* __lhs,
     ^
/usr/include/c++/5/bits/basic_string.tcc:1151:5: note:   template argument deduction/substitution failed:
prog.cpp:17:49: note:   mismatched types 'const _CharT*' and 'std::_List_iterator<int>'
         auto mid = nums.begin() + nums.size() / 2;
                                                 ^
In file included from /usr/include/c++/5/string:52:0,
                 from /usr/include/c++/5/bits/locale_classes.h:40,
                 from /usr/include/c++/5/bits/ios_base.h:41,
                 from /usr/include/c++/5/ios:42,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/5/bits/basic_string.h:4781:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
     ^
/usr/include/c++/5/bits/basic_string.h:4781:5: note:   template argument deduction/substitution failed:
prog.cpp:17:49: note:   'std::list<int>::iterator {aka std::_List_iterator<int>}' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'
         auto mid = nums.begin() + nums.size() / 2;
                                                 ^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/5/bits/char_traits.h:39,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/5/bits/stl_iterator.h:1152:5: note: candidate: template<class _Iterator> std::move_iterator<_Iterator> std::operator+(typename std::move_iterator<_Iterator>::difference_type, const std::move_iterator<_Iterator>&)
     operator+(typename move_iterator<_Iterator>::difference_type __n,
     ^
/usr/include/c++/5/bits/stl_iterator.h:1152:5: note:   template argument deduction/substitution failed:
prog.cpp:17:49: note:   mismatched types 'const std::move_iterator<_Iterator>' and 'std::list<int>::size_type {aka unsigned int}'
         auto mid = nums.begin() + nums.size() / 2;
                                                 ^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/5/bits/char_traits.h:39,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/5/bits/stl_iterator.h:334:5: note: candidate: template<class _Iterator> std::reverse_iterator<_Iterator> std::operator+(typename std::reverse_iterator<_Iterator>::difference_type, const std::reverse_iterator<_Iterator>&)
     operator+(typename reverse_iterator<_Iterator>::difference_type __n,
     ^
/usr/include/c++/5/bits/stl_iterator.h:334:5: note:   template argument deduction/substitution failed:
prog.cpp:17:49: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'std::list<int>::size_type {aka unsigned int}'
         auto mid = nums.begin() + nums.size() / 2;
                                                 ^
stdout
Standard output is empty