C++11
I am trying to make a vector
of std::thread
s. The combination of the following three points says I can.
1.)
Your first example is correct. Throwing an exception is a known bug, when you using clang with libstdc++. To solve it, you have to install libc++(llvm version of c++ library). See an example of compiling with libc++ below
#include <thread>
int main()
{
std::thread t([] () {});
t.join();
return 0;
}
$ clang++ -std=c++11 -stdlib=libc++ main.cpp -o main -lc++ -lsupc++ -lpthread
P.S. See here, why is the flag -lsupc++
required too.