deducing this {C++23}
Bing Chat answer#
Here is a summary of the page in Microsoft Edge:
- C++23’s Deducing this: what it is, why it is, how to use it: The page is a blog post by Sy Brand, a C++ developer advocate, explaining the new feature of explicit object parameters in C++23, which allows specifying the implicit object parameter of a member function explicitly1.
- Motivation: The feature was motivated by the need to avoid code duplication and improve performance for member functions that need to handle different const/volatile/reference qualifiers of the object they are called on, such as std::optional::value.
- Design: The feature follows the principle of doing what the user expects, and does not change the existing rules of overload resolution, template deduction, or name resolution2. The explicit object parameter is distinguished by the keyword this before the type specifier, and can be a template parameter that is deduced from the expression used to call the member function3.
- Use Cases: The page illustrates several use cases for the feature, such as de-duplication of code, CRTP, forwarding out of lambdas, recursive lambdas, passing this by value, and SFINAE-unfriendly callables4. The page also provides code examples and links to other resources for more information.