Better Code with C++ Attributes
summary
Explains concrete attributes and their effects: [[noreturn]] prevents return-path code generation and avoids unreachable-code surprises but causes undefined behavior if the function actually returns; [[deprecated]]("use write") emits migration warnings with custom messages; [[fallthrough]] suppresses unwanted fallthrough warnings; [[maybe_unused]] suppresses assert-driven unused-parameter noise; [[nodiscard]] for error codes helps catch ignored returns; [[no_unique_address]] to shrink objects lets empty policy members share padding and can reduce a struct from 12 to 8 bytes; C++20 also adds [[likely]]/[[unlikely]] branch hints.
AI-written summary · about
chapters (3)
related talks
01h 01mEasy to Use, Hard to Misuse: Declarative Style in C++
22mWhat happened to...: Deprecated and Removed Features of C++
01h 21mProgramming with Contracts in C++20
48mTo Pass and Return — The Story of Functions, Values and Compilers
58mExploration of C++20 Meta Programming
37mMemory Safety Everywhere with Both Rust and Carbon
01h 39m“Thoughts on a more powerful and simpler C++ (5 of N)”
46m“My Little Optimizer: Undefined Behavior is Magic"
