Week 2 Lecture 1 - More C++
We spent today debugging the Voroni assignments.
Takeaway points:
1) Don't do subtraction between signed and unsigned integers (this includes size_t).
2) The compiler will warn you about this if you have -Wall turned on, so always turn on -Wall (and -Wextra maybe) and always clear your warnings
3) You can use attributes like [[maybe_unused]] to tell the compiler when you're deliberately not using something to turn off warnings on it. Again, you always want no warnings when you compile your code.
4) You can use lambdas to make anonymous little functions to do things like sorting or finding the max_element of a vector without needing to add a member function or global function to do so, which is nice if it's a one-off thing.
5) It's really important to have the right compiler settings when doing development in C++. Especially when you're a new programmer, turn on -fsanitize=address, -fsanitize=undefined, -Wall and -Wextra by default to catch a lot of bugs.