https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107886

--- Comment #8 from Jamaika <lukaszcz18 at wp dot pl> ---
First lesson on the page https://www.modernescpp.com/index.php/latches-in-c-20
I use GCC from 11.3.1 to 13.0.0 20221124
```
// workers.cpp

#include <iostream>
#include <latch>
#include <mutex>
#include <thread>

std::latch workDone(6);
std::mutex coutMutex;

void synchronizedOut(const std::string& s) {
    std::lock_guard<std::mutex> lo(coutMutex);
    std::cout << s;
}

class Worker {
 public:
    Worker(std::string n): name(n) { };

    void operator() () {
        synchronizedOut(name + ": " + "Work done!\n");
        workDone.arrive_and_wait();  // wait until all work is done  (1)
        synchronizedOut(name + ": " + "See you tomorrow!\n");
    }
 private:
    std::string name;
};

int main() {

    std::cout << '\n';

    Worker herb("  Herb");
    std::thread herbWork(herb);

    Worker scott("    Scott");
    std::thread scottWork(scott);

    Worker bjarne("      Bjarne");
    std::thread bjarneWork(bjarne);

    Worker andrei("        Andrei");
    std::thread andreiWork(andrei);

    Worker andrew("          Andrew");
    std::thread andrewWork(andrew);

    Worker david("            David");
    std::thread davidWork(david);

    herbWork.join();
    scottWork.join();
    bjarneWork.join();
    andreiWork.join();
    andrewWork.join();
    davidWork.join();

}
```
I have error.
workers.cpp:8:6: error: 'latch' in namespace 'std' does not name a type
    8 | std::latch workDone(6);
      |      ^~~~~
When I use 'latch.h' gcc 11.3.0 and above hasn't problem.
https://github.com/luncliff/latch/blob/master/latch.h
I have not error.

Reply via email to