C++11 理解“中的thread::join()时的混乱;C++;程序设计语言; STL阅读新的线程类时,Bjarne Stroustrup阅读了“C++编程语言,第四版”,第42.2.4节()。它有一个示例代码,这让我很困惑 void run(i

C++11 理解“中的thread::join()时的混乱;C++;程序设计语言; STL阅读新的线程类时,Bjarne Stroustrup阅读了“C++编程语言,第四版”,第42.2.4节()。它有一个示例代码,这让我很困惑 void run(i,c++11,C++11,理解“中的thread::join()时的混乱;C++;程序设计语言; STL阅读新的线程类时,Bjarne Stroustrup阅读了“C++编程语言,第四版”,第42.2.4节()。它有一个示例代码,这让我很困惑 void run(int i, int n) // warning: really poor code { thread t1 {f}; thread t2; vector<Foo> v; // ... if (

理解“中的thread::join()时的混乱;C++;程序设计语言; <> STL阅读新的线程类时,Bjarne Stroustrup阅读了“C++编程语言,第四版”,第42.2.4节()。它有一个示例代码,这让我很困惑

void run(int i, int n) // warning: really poor code
{
    thread t1 {f};
    thread t2;
    vector<Foo> v;
    // ...
    if (i<n) {
        thread t3 {g};
        // ...
        t2 = move(t3); // move t3 to outer scope
    }
    v[i] = Foo{}; // might throw
    // ...
    t1.join();
    t2.join();
}
void run(inti,intn)//警告:代码太差了
{
线程t1{f};
螺纹t2;
向量v;
// ...

如果(它的键是
//可能抛出
。谢谢T.C.,这就解释了键是
//可能抛出
。谢谢T.C.,这就解释了