boost::thread_group in C++11?

No, there's nothing directly equivalent to boost::thread_group in C++11. You could use a std::vector<std::thread> if all you want is a container. You can then use either the new for syntax or std::for_each to call join() on each element, or whatever.


thread_group didn't make it into C++11, C++14, C++17 or C++20 standards.

But a workaround is simple:

  std::vector<std::thread> grp;

  // to create threads
  grp.emplace_back(functor); // pass in the argument of std::thread()

  void join_all() {
    for (auto& thread : grp)
        thread.join();
  }

Not even worth wrapping in a class (but is certainly possible).