Summary
This episode explores C++23's 'deducing this' feature, which solves the common problem of duplicating code when implementing both const and non-const versions of member functions. Jason demonstrates how this new feature eliminates the need for code duplication or helper functions by allowing member functions to deduce the constness and value category of the object they're called on. The feature works by specifying the first parameter as a reference to the class type, effectively treating the 'this' pointer as an explicit parameter.
Related C++ Standard Sections
This episode covers topics found in these sections of the C++ standard:
-
[expr.prim.this]63% match -
[class.static.mfct]62% match -
[diff.cpp17.class]54% match -
[diff.class]54% match -
[locale.facet]50% match -
[array]40% match