oneTBB icon indicating copy to clipboard operation
oneTBB copied to clipboard

Mark relevant functions noexcept

Open Lastique opened this issue 3 years ago • 3 comments

Please mark relevant functions in TBB noexcept. In particular, consider these members:

  • Default constructors, where possible
  • Move constructors
  • Move assignment
  • swap members and free functions
  • Comparison operators
  • Hash functions

Having the correct noexcept specification is important for:

  • User's types that use TBB types for members. Default constructors, assignment and comparison functions inherit noexcept specification from the corresponding functions of the class' members, so if the TBB type omits noexcept, the downstream type also does.
  • swap is often used in contexts where failure is not an option (e.g. as a means to roll back a failed operation, e.g. to maintain strong guarantee). Thus it is strongly preferred to be a non-throwing operation. swap is also sometimes used for move implementation.
  • Having move constructors noexcept is important for some containers, e.g. std::vector, as this allows for a more optimal implementation of some of its operations.
  • Having comparison and hash functions noexcept ensures that lookup functions in associative containers will not throw.

Lastique avatar Dec 03 '21 12:12 Lastique

clang-tidy might help to find move constructors and assign operators

anton-potapov avatar Mar 11 '22 12:03 anton-potapov

@isaevil , FYI

anton-potapov avatar Mar 11 '22 12:03 anton-potapov