If statement with initializer

1 · · June 26, 2024, midnight
Summary
What it is This feature was added in C++17. What does it mean for us? We can initialize a variable inside if statement, and perform the actual conditional check after initialization. Statement Equivalent Iterations if (init; cond) E; { init; while(cond) { E; break; } } Once while cond holds if (init; cond) E; else F; (more complex) Once Tehnically, new if looks like: if (init; condition) Guard clause Here is example of guard clause: AMyPlayerCharacter* PC = UMyFunctionLibrary::GetMy...