Modern C++ equivalent of Python os.cpu_count()

The C++ equivalent (since C++11 from 2011) of Python’s

os.cpu_count()

is

#include <thread>

std::thread::hardware_concurrency()

Also see the docs for std::thread::hardware_concurrency() on cppreference.com.