Talk:cpp/language/if

Hi,

I want to ask about the case in the `constexpr if` section.

In the standard (8.5.1.2), it says "During the instantiation of an enclosing templated entity (13.1), if the condition is not value-dependent after its instantiation, the discarded substatement (if any) is not instantiated."

But what's the case that a expression could be not value-dependent after its instantiation?

The cppreference gives a example (https://en.cppreference.com/w/cpp/language/if):

But I don't think this is the same case with the standard. The standard says "after its instantiation", but the example says "this condition remains value-dependent after instantiation of g". I think in this case, "its" should be the generic lambda.

Could anyone explain this to me?

Thanks very much.


 * We intendedly show a counterexample. It would be an example of the case if the condition is replaced with . --Fruderica (talk) 05:14, 15 July 2020 (PDT)

I am still confused for the example. In my minds, when the lambda instantiating, the g must have instantiated.

errors in example
In the example supplied with the if with initializers there are several undefined entities. Most notably the capture [&s], unsafe_ping and an other line with multiple problems.

The capture is annoying as there is an s in the block, but it is hidden inside the if. 2001:980:90E5:1:E1A:8100:56E1:3DED 01:49, 13 July 2021 (PDT)


 * yes, that code fragment isn't intended to be compilable. It shows motivational use cases lifted directly from the proposal. I suppose it does look a little too crowded the way it's rendered here. --Cubbi (talk) 15:12, 13 July 2021 (PDT)