News for hackers. Stuff that matters.
Re:“I'm basically giving myself a permanent vacation from be... by iainmerrick on Thursday July 12, 2018 @03:16PM (#17517715)
What do you do if you really do intend the assignment?

(Assume for the sake of argument it’s some more reasonable example like "if (x = re_match(foo, bar)) {...}")

Re:“I'm basically giving myself a permanent vacation from be... by 613style on Thursday July 12, 2018 @03:30PM (#17517838)
You wrap it in parens to avoid the warning: if ((x = 7)) { ... }
Re:“I'm basically giving myself a permanent vacation from be... by thestoicattack on Thursday July 12, 2018 @04:17PM (#17518252)
C++17 has if-statement initializers, so you can do

    if (auto x = re_match(foo, bar); x.has_value()) {
(or x.ok() or whatever the name is of the method that tells you the validity of x)
Re:“I'm basically giving myself a permanent vacation from be... by Tyr42 on Thursday July 12, 2018 @03:36PM (#17517895)
You do "if (((x = re_match(foo, bar))) {...}".

At least the systems I've seen need a extra (()) around = to disable the warnings and notify the reader that you're not just comparing for equality.