Я хотел протестировать некоторые вещи с потоками на моем MacBook Pro, но не могу заставить его работать.
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
это версия clang, установленная на моей машине. Я попытался закодировать некоторый вектор потоков, но это не сработало, поэтому я вернулся и скопировал пример из SO.
#include <string>
#include <iostream>
#include <thread>
using namespace std;
// The function we want to execute on the new thread.
void task1(string msg)
{
cout << "task1 says: " << msg;
}
int main()
{
// Constructs the new thread and runs it. Does not block execution.
thread t1(task1, "Hello");
// Do other things...
// Makes the main thread wait for the new thread to finish execution, therefore blocks its own execution.
t1.join();
}
Но я получаю ошибку компилятора ..
error: no matching constructor for initialization of
'std::__1::thread'
thread t1(task1, "Hello");
Полагаю, проблема в моей машине, но почему?