10 for (
int i = cpulo; i != cpuhi + 1; ++i) {
18 for (
int i = cpulo; i != cpuhi + 1; ++i) {
28 for (std::istringstream is(value);
29 is.good() and std::getline(is, element,
',');) {
30 std::istringstream el(element);
32 std::getline(el, lo,
'-');
41 if (not std::getline(el, hi,
'-') or not el.eof()) {
46 tmp.
set(cpulo, cpuhi);
56 std::ostringstream os;
58 for (
int i = 0; std::size_t(i) <
capacity(); ++i) {
66 if (end != i + 1 or std::size_t(end) ==
capacity()) {
76 if (cpu >= 0 and std::size_t(cpu) <
capacity()) {
79 std::ostringstream os;
80 os <<
"cpu_set::" << op <<
"(" << cpu <<
") - argument out of range " 82 throw std::out_of_range(os.str());
86 if (cpulo < 0 or std::size_t(cpuhi) >=
capacity()) {
87 std::ostringstream os;
88 os <<
"cpu_set::" << op <<
"(" << cpulo <<
"," << cpuhi <<
")" 89 <<
"- argument out of expected range [0," <<
capacity() - 1 <<
"]";
90 throw std::out_of_range(os.str());
96 os <<
"cpu_set::parse() - invalid argument (" << value <<
")";
97 throw std::invalid_argument(os.str());
108 rhs = std::move(tmp);
std::ostream & operator<<(std::ostream &os, as_hhmmssu const &x)
Format as_hhmmssu into an iostream.
std::size_t capacity() const
Return the number of CPUs that can be stored in the cpu set.
bool status(int cpu) const
Returns true if cpu is included in the cpu set.
cpu_set & clear(int cpu)
Remove cpu from the cpu set.
std::string as_list_format() const
Return the set in the list format representation.
bool strtonum(std::string const &s, T &r)
Generic string to number conversion with validation.
static cpu_set parse(std::string const &value)
Interpret value as a cpu set in list format.
std::istream & operator>>(std::istream &, cpu_set &)
Read a cpu set in list format.
void check_range(int cpu, char const *op) const
Check that cpu is in range.
cpu_set & set(int cpu)
Add cpu to the cpu set.
static void parse_error(std::string const &value)
Raise an exception because the input to parse() is invalid.
A wrapper for the Linux CPU_SET data structure.