1. 11
  1.  

  2. 3

    Yes, C++ has a lot to learn from Rust. I wish this would be done more. Good, Microsoft!

    The only thing I feel like commenting:

    The first rule, exhaustive checking, can be enforced by gcc/clang by compiling with -Werror=switch, however only for enum switches, and only when not having a default in the switch.

    There are guidelines that demand every switch statement to have a default (e.g. MISRA C). I call such guidelines misguided for the reason above – no need to make runtime errors out of compile time errors – and recommend breaking them specifically for enum switches. For once, Google’s C++ style guide gets this right.

    1. 1

      These all seem like good things, especially the copying auto case as it’s super easy error to make (auto a = reference; results in a having a copy of the value not the reference)