i got a minimal example from http://ift.tt/1cF1r9u for the implementation of threads.
Unfortunately this example did not compile and ERROR C2664 is thrown:
// thread example
#include <iostream> // std::cout
#include <thread> // std::thread
void foo()
{
// do stuff...
}
void bar(int x)
{
// do stuff...
}
int main()
{
std::thread first (foo); // spawn new thread that calls foo()
std::thread second (bar,0); // spawn new thread that calls bar(0)
std::cout << "main, foo and bar now execute concurrently...\n";
// synchronize threads:
first.join(); // pauses until first finishes
second.join(); // pauses until second finishes
std::cout << "foo and bar completed.\n";
return 0;
}
error C2664: 'std::thread::thread(const std::thread &)' : cannot convert argument n from 'void' to 'std::thread &&'
Can someone explain what ist wrong with the example // with Visual Studio?
Thanks
Aucun commentaire:
Enregistrer un commentaire