fork(1) download
  1. #include <thread>
  2. #include <vector>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. void fun(vector<int> & v) {
  7. v.push_back(13);
  8. }
  9. vector<int> v;
  10. int main(){
  11.  
  12. thread t(fun, v);
  13. t.join();
  14. cout << v.size();
  15. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
In file included from prog.cpp:1:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/thread:39:
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/functional:1365:56: error: no type named 'type' in 'std::result_of<void (*(std::vector<int, std::allocator<int> >))(std::vector<int, std::allocator<int> > &)>'
      typedef typename result_of<_Callable(_Args...)>::type result_type;
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/thread:138:8: note: in instantiation of template class 'std::_Bind_simple<void (*(std::vector<int, std::allocator<int> >))(std::vector<int, std::allocator<int> > &)>' requested here
              std::__bind_simple(std::forward<_Callable>(__f),
              ^
prog.cpp:12:9: note: in instantiation of function template specialization 'std::thread::thread<void (&)(std::vector<int, std::allocator<int> > &), std::vector<int, std::allocator<int> > &>' requested here
        thread t(fun, v);
               ^
In file included from prog.cpp:1:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/thread:39:
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/functional:1385:50: error: no type named 'type' in 'std::result_of<void (*(std::vector<int, std::allocator<int> >))(std::vector<int, std::allocator<int> > &)>'
        typename result_of<_Callable(_Args...)>::type
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
2 errors generated.
stdout
Standard output is empty