powerd++
0.4.4
|
A read once representation of a Sysctl. More...
#include <sysctl.hpp>
Public Member Functions | |
Once (T const &value, SysctlT const &sysctl) noexcept | |
The constructor tries to read and store the requested sysctl. More... | |
operator T const & () const | |
Return a const reference to the value. More... | |
Private Attributes | |
T | value |
The sysctl value read upon construction. | |
A read once representation of a Sysctl.
This reads a sysctl once upon construction and always returns that value. It does not support assignment.
This class is intended for sysctls that are not expected to change, such as hw.ncpu. A special property of this class is that the constructor does not throw and takes a default value in case reading the sysctl fails.
T | The type to represent the sysctl as |
SysctlT | The Sysctl type |
|
inlinenoexcept |
The constructor tries to read and store the requested sysctl.
If reading the requested sysctl fails for any reason, the given value is stored instead.
value | The fallback value |
sysctl | The sysctl to represent |
|
inline |
Return a const reference to the value.