fork download
  1. #include <vector>
  2. #include <string>
  3. #include <iostream>
  4.  
  5. using std::vector;
  6. using std::string;
  7. using std::cout;
  8. using std::cin;
  9. using std::endl;
  10.  
  11. int main()
  12. {
  13. string s1 = "AreYouOK";
  14. vector<string> v;
  15.  
  16. for (string::const_iterator iter = s1.begin();
  17. iter != s1.end()-1; ++iter)
  18. {
  19. string s(s1.begin(),iter); // no matching container
  20. s += *iter;
  21. v.push_back(s);
  22. }
  23.  
  24. for (vector<string>::const_iterator iter = v.begin();
  25. iter != v.end(); ++iter)
  26. {
  27. cout << *iter <<endl;
  28. }
  29.  
  30. return 0;
  31. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:19:33: error: no matching function for call to 'std::basic_string<char>::basic_string(std::basic_string<char>::iterator, std::basic_string<char>::const_iterator&)'
         string s(s1.begin(),iter); // no matching container
                                 ^
In file included from /usr/include/c++/5/string:52:0,
                 from prog.cpp:2:
/usr/include/c++/5/bits/basic_string.h:2936:9: note: candidate: template<class _InputIterator> std::basic_string<_CharT, _Traits, _Alloc>::basic_string(_InputIterator, _InputIterator, const _Alloc&)
         basic_string(_InputIterator __beg, _InputIterator __end,
         ^
/usr/include/c++/5/bits/basic_string.h:2936:9: note:   template argument deduction/substitution failed:
prog.cpp:19:33: note:   deduced conflicting types for parameter '_InputIterator' ('__gnu_cxx::__normal_iterator<char*, std::basic_string<char> >' and '__gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >')
         string s(s1.begin(),iter); // no matching container
                                 ^
In file included from /usr/include/c++/5/string:52:0,
                 from prog.cpp:2:
/usr/include/c++/5/bits/basic_string.h:2926:7: note: candidate: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::initializer_list<_Tp>, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc());
       ^
/usr/include/c++/5/bits/basic_string.h:2926:7: note:   no known conversion for argument 1 from 'std::basic_string<char>::iterator {aka __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >}' to 'std::initializer_list<char>'
/usr/include/c++/5/bits/basic_string.h:2908:7: note: candidate: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       basic_string(basic_string&& __str)
       ^
/usr/include/c++/5/bits/basic_string.h:2908:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/5/bits/basic_string.h:2898:7: note: candidate: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::basic_string<_CharT, _Traits, _Alloc>::size_type, _CharT, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
       basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc());
       ^
/usr/include/c++/5/bits/basic_string.h:2898:7: note:   no known conversion for argument 1 from 'std::basic_string<char>::iterator {aka __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >}' to 'std::basic_string<char>::size_type {aka unsigned int}'
/usr/include/c++/5/bits/basic_string.h:2891:7: note: candidate: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       basic_string(const _CharT* __s, const _Alloc& __a = _Alloc());
       ^
/usr/include/c++/5/bits/basic_string.h:2891:7: note:   no known conversion for argument 1 from 'std::basic_string<char>::iterator {aka __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >}' to 'const char*'
/usr/include/c++/5/bits/basic_string.h:2884:7: note: candidate: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, std::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
       basic_string(const _CharT* __s, size_type __n,
       ^
/usr/include/c++/5/bits/basic_string.h:2884:7: note:   no known conversion for argument 1 from 'std::basic_string<char>::iterator {aka __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >}' to 'const char*'
/usr/include/c++/5/bits/basic_string.h:2872:7: note: candidate: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc>&, std::basic_string<_CharT, _Traits, _Alloc>::size_type, std::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
       basic_string(const basic_string& __str, size_type __pos,
       ^
/usr/include/c++/5/bits/basic_string.h:2872:7: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/5/bits/basic_string.h:2863:7: note: candidate: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc>&, std::basic_string<_CharT, _Traits, _Alloc>::size_type, std::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
       basic_string(const basic_string& __str, size_type __pos,
       ^
/usr/include/c++/5/bits/basic_string.h:2863:7: note:   no known conversion for argument 1 from 'std::basic_string<char>::iterator {aka __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >}' to 'const std::basic_string<char>&'
/usr/include/c++/5/bits/basic_string.h:2856:7: note: candidate: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       basic_string(const basic_string& __str);
       ^
/usr/include/c++/5/bits/basic_string.h:2856:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/5/bits/basic_string.h:2849:7: note: candidate: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       basic_string(const _Alloc& __a);
       ^
/usr/include/c++/5/bits/basic_string.h:2849:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/5/bits/basic_string.h:2838:7: note: candidate: std::basic_string<_CharT, _Traits, _Alloc>::basic_string() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       basic_string()
       ^
/usr/include/c++/5/bits/basic_string.h:2838:7: note:   candidate expects 0 arguments, 2 provided
stdout
Standard output is empty