-
Book Overview & Buying
-
Table Of Contents
Software Architecture with C++ - Second Edition
By :
C++23 introduced an explicit object parameter, also known as deducing this. The parameter does not change type deduction, but allows you to declare the implicit this parameter explicitly. This opens up new horizons for us, such as code deduplication, recursive lambdas, and CRTP replacement.
Combined with type deduction, the explicit object parameter allows us to define one generic method instead of four declared with cv- or ref-qualifiers (&, const&, &&, const&&), which reduces boilerplate code.
However, functions declared with the explicit object parameter cannot be declared as static or virtual, nor can they have cv- or ref-qualifiers. Inheritance is supported as the explicit objects deduce the types of derived objects. Moreover, the only way to interact with a class object inside such functions is through the explicit object parameter, because the function behaves like a static member function, so this, a pointer to the...