News for hackers. Stuff that matters.
Re:What's new in C++26 (part 1) by quietbritishjim on Saturday September 07, 2024 @09:27AM (#41473833)
> The result of the expression is the condition. Thus, in your example, the bool check would apply to "s", after the expression is evaluated.

This is a contradiction. There is no expression in my code that evaluates to s. foo() is an expression, and then std::string s = ... is assignment initialisation, which is not an expression.

Edit: I suppose that if I used another form of initialisation, the answer becomes a bit more obvious:

   if (std::string s('x', 3))
(Not that this makes sense but just the point is to use a constructor with more than one argument.) In this case it's clear the test has to be the just-initialised variable. In fact there could be no arguments at all!
Re:What's new in C++26 (part 1) by muststopmyths on Saturday September 07, 2024 @09:43AM (#41473901)
You are using definitions that I am not familiar with. Maybe it's because we speak different programming languages :-)

x = y is an expression statement in C++, which can be evaluated in an "if" for its side-effects.

https://en.wikipedia.org/wiki/Expression_(computer_science)

Re:What's new in C++26 (part 1) by layer8 on Saturday September 07, 2024 @09:53AM (#41473955)
But Type x = y isn’t.