Which standard C++ features can be used for querying machine/OS architecture?
c++, c++11, c++14, cpu-architecture
Solution
As others have pointed out, functions for obtaining such properties of the system are typically platform-specific. The STL and boost do not provide platform-independent wrappers, so you'll have to rely on other third party libraries.
I've successfully used SIGAR in the past:
The Sigar API provides a portable interface for gathering system information such as:
- System memory, swap, cpu, load average, uptime, logins
- Per-process memory, cpu, credential info, state, arguments, environment, open files
- File system detection and metrics
- Network interface detection, configuration info and metrics
- TCP and UDP connection tables
- Network route table
As a side note, Boost Filesystem does actually provide boost::filesystem::space to query "how much disk space is available to write to in a certain directory".
Problem
What are the standard C++ features and utilities for querying the properties of the hardware or operating system capabilities, on which the program is running? For instance, `std::thread::hardware_concurrency()` gives you the number of threads the machine supports. But how do you detect how much RAM the computer has, or how much RAM the process is using, or how much disk space is available to write to in a certain directory, or how much L2 cache is available? I would prefer answers by means of c++ (c++14) standards, but TR2 or boost proposals would be good as well.