Noexcept? Enabling Testing of Contract Checks in C++ - Pablo Halpern & Timur Doumler - CppCon 2023

Enabling testing of contract checks in C++ with `noexcept`, a crucial optimization technique for ensuring code correctness, tested.

Key takeaways
  • The noexcept operator is used to optimize code, not to make it faster.
  • Contracts in C++ are important for ensuring the correctness of code, and noexcept can be used to enable testing of contract checks.
  • A wide contract is one that doesn’t have any preconditions, while a narrow contract is one that does.
  • The noexcept operator can be used to indicate that a function does not throw exceptions, which can be useful for optimization.
  • Precondition checks can be used to ensure that functions are called correctly, and noexcept can be used to enable testing of these checks.
  • Postcondition checks can be used to ensure that functions return the correct results, and noexcept can be used to enable testing of these checks.
  • The noexcept operator can be used to indicate that a function is allowed to throw, which can be useful for error handling.
  • Death tests are a type of testing that can be used to test contract checks, but they are not widely available in C++ unit testing frameworks.
  • The noexcept operator can be used to enable testing of contract checks in a way that is faster and more efficient than other testing methods.
  • The noexcept operator can be used to optimize code, but it is not necessary for error handling.
  • Contracts in C++ are important for ensuring the correctness of code, and noexcept can be used to enable testing of these contracts.
  • The noexcept operator can be used to indicate that a function does not throw exceptions, which can be useful for optimization.
  • Precondition checks can be used to ensure that functions are called correctly, and noexcept can be used to enable testing of these checks.
  • Postcondition checks can be used to ensure that functions return the correct results, and noexcept can be used to enable testing of these checks.