if、switch 与分支设计 | C++

本章覆盖:`if`;`else if`;`else`;`switch`;`case`;`default`;fallthrough;`[[fallthrough]]`;initializer in if / switch;early return;guard clause;大型状态机不应无限堆叠 if-else。

本章知识点

  • if
  • else if
  • else
  • switch
  • case
  • default
  • fallthrough
  • [[fallthrough]]
  • initializer in if / switch
  • early return
  • guard clause
  • 大型状态机不应无限堆叠 if-else