fork download
  1. #include <vector>
  2. #include <string>
  3.  
  4. void foo(const std::vector<const std::string> &arg){}
  5.  
  6. int main() {
  7. std::vector<std::string> v = {"hello", "world"};
  8. foo(v);
  9. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
In file included from /usr/include/i386-linux-gnu/c++/5/bits/c++allocator.h:33:0,
                 from /usr/include/c++/5/bits/allocator.h:46,
                 from /usr/include/c++/5/vector:61,
                 from prog.cpp:1:
/usr/include/c++/5/ext/new_allocator.h: In instantiation of 'struct __gnu_cxx::new_allocator<const std::basic_string<char> >':
/usr/include/c++/5/bits/allocator.h:92:11:   required from 'class std::allocator<const std::basic_string<char> >'
/usr/include/c++/5/bits/alloc_traits.h:88:43:   required from 'struct std::allocator_traits<std::allocator<const std::basic_string<char> > >'
/usr/include/c++/5/ext/alloc_traits.h:95:10:   required from 'struct __gnu_cxx::__alloc_traits<std::allocator<const std::basic_string<char> > >'
/usr/include/c++/5/bits/stl_vector.h:75:28:   required from 'struct std::_Vector_base<const std::basic_string<char>, std::allocator<const std::basic_string<char> > >'
/usr/include/c++/5/bits/stl_vector.h:214:11:   required from 'class std::vector<const std::basic_string<char> >'
prog.cpp:8:7:   required from here
/usr/include/c++/5/ext/new_allocator.h:93:7: error: 'const _Tp* __gnu_cxx::new_allocator<_Tp>::address(__gnu_cxx::new_allocator<_Tp>::const_reference) const [with _Tp = const std::basic_string<char>; __gnu_cxx::new_allocator<_Tp>::const_pointer = const std::basic_string<char>*; __gnu_cxx::new_allocator<_Tp>::const_reference = const std::basic_string<char>&]' cannot be overloaded
       address(const_reference __x) const _GLIBCXX_NOEXCEPT
       ^
/usr/include/c++/5/ext/new_allocator.h:89:7: error: with '_Tp* __gnu_cxx::new_allocator<_Tp>::address(__gnu_cxx::new_allocator<_Tp>::reference) const [with _Tp = const std::basic_string<char>; __gnu_cxx::new_allocator<_Tp>::pointer = const std::basic_string<char>*; __gnu_cxx::new_allocator<_Tp>::reference = const std::basic_string<char>&]'
       address(reference __x) const _GLIBCXX_NOEXCEPT
       ^
prog.cpp: In function 'int main()':
prog.cpp:8:7: error: invalid initialization of reference of type 'const std::vector<const std::basic_string<char> >&' from expression of type 'std::vector<std::basic_string<char> >'
  foo(v);
       ^
prog.cpp:4:6: note: in passing argument 1 of 'void foo(const std::vector<const std::basic_string<char> >&)'
 void foo(const std::vector<const std::string> &arg){}
      ^
stdout
Standard output is empty