33. Tabular printing of a list of processes

To solve this problem, we will consider the following class representing information about a process:

enum class procstatus {suspended, running};enum class platforms {p32bit, p64bit};struct procinfo{   int         id;   std::string name;   procstatus  status;   std::string account;   size_t      memory;   platforms   platform;};

In order to print the status and platform as text and not as numerical values, we need conversion functions from the enumerations to std::string:

std::string status_to_string(procstatus const status){   if (status == procstatus::suspended) return "suspended";   else return "running";}std::string platform_to_string(platforms const platform){   if (platform == platforms::p32bit) return "32-bit"; else return ...

Get The Modern C++ Challenge now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.