Skip to content

Commit

Permalink
Postfix ++, impl. for read, bi-side operator fixes for str
Browse files Browse the repository at this point in the history
  • Loading branch information
aarikpokras authored Dec 10, 2024
1 parent 8097f11 commit 8f29480
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/io.cxlbund/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ struct num {
void operator/=(const num& o) {
c /= o.c;
}
void operator++() {
void operator++(int) {
c++;
}
void operator--() {
void operator--(int) {
c--;
}
bool operator==(const num& o) {
Expand Down Expand Up @@ -119,14 +119,14 @@ struct str {
int size() {
return c[0].size();
}
str operator+(const str& o) {
friend str operator+(const str& l, const str& r) {
std::vector<std::string> ret;

ret.push_back("");
ret.push_back("");

ret[0] = c[0].c_str();
ret[1] = o.c[0].c_str();
ret[0] = l.c[0].c_str();
ret[1] = r.c[0].c_str();
std::string ret_f = ret[0] + ret[1]; // Take advantage of std::string's concat.
return str(ret_f); // This uses the std::string constructor
}
Expand All @@ -151,3 +151,4 @@ struct str {

void prints(str s);
str chomp(str what);
str read();

0 comments on commit 8f29480

Please sign in to comment.