C++ already supports compact assign and compare expressions, since assigning returns the updated value. What you describe can be written as:
char const *o = ch;
char const *a = ch;
while ((o = strstr(o, "||")) != nullptr &&
(a = strstr(a, "&&")) != nullptr) {
/*...*/
}
or more succintly (since comparing with nullptr
is just checking a truthy value):
char const *o = ch;
char const *a = ch;
while ((o = strstr(o, "||")) && (a = strstr(a, "&&"))) {
/*...*/
}
the only caveat is that due to short-circuiting, the second assignment only happens when the first condition evaluates to true. Here's an example.