From Jason Turner
Watch on YouTube

Summary

Jason explores clang-tidy's "bugprone-easily-swappable-parameters" warning, which flags when functions have multiple adjacent parameters of the same type that could be accidentally swapped during function calls. Using the example of a clamp function with three int parameters, he demonstrates two approaches to resolve this warning: using enum classes to create stronger type distinctions, and grouping related parameters into a properly named struct. The latter approach not only improves code clarity but may also offer potential performance benefits through more efficient parameter passing.

Resources

Tags