vector of std::threads

前端 未结 1 2087
醉梦人生
醉梦人生 2020-12-31 04:59

C++11

I am trying to make a vector of std::threads. The combination of the following three points says I can.

1.)

相关标签:
1条回答
  • 2020-12-31 06:03

    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.

    0 讨论(0)
提交回复
热议问题