multithreading - C++ Visual Studio 13 using threads: minimal example not working -


i got minimal example http://www.cplusplus.com/reference/thread/thread/ implementation of threads.

unfortunately example did not compile , error c2664 thrown:

// thread example #include <iostream>       // std::cout #include <thread>         // std::thread  void foo()  {   // stuff... }  void bar(int x) {   // stuff... }  int main()  {   std::thread first (foo);     // spawn new thread calls foo()   std::thread second (bar,0);  // spawn new thread calls bar(0)    std::cout << "main, foo , bar execute concurrently...\n";    // synchronize threads:    first.join();                // pauses until first finishes   second.join();               // pauses until second finishes    std::cout << "foo , bar completed.\n";    return 0; } 

error c2664: 'std::thread::thread(const std::thread &)' : cannot convert argument 1 'void' 'std::thread &&'

can explain ist wrong example // visual studio?

thanks

the above code works in vs 2013 (but in vs 2012, vs 2015).

try create new project , copy code there. vs behaves strange sometimes. removing .sdf file may "build -> clean solution".


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -