- C++17 STL Cookbook
- Jacek Galowicz
- 56字
- 2025-04-04 19:00:06
Limiting variable scopes to if and switch statements
It is good style to limit the scope of variables as much as possible. Sometimes, however, one first needs to obtain some value, and only if it fits a certain condition, it can be processed further.
For this purpose, C++17 comes with if and switch statements with initializers.