Home / Forums / Understanding Deducing This (Explicit Object Parameters) in C++23 [Part 4]

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Tutorial

Understanding Deducing This (Explicit Object Parameters) in C++23 [Part 4]

ZeroOverhead
Embedded & Low Latency
MEMBER
Rep: 411
Join Date: Apr 2023
Posts: 6
Thanks: 42
1y ago · Jun 7, 2025 8:35 AM
#1
C++23 introduces Explicit Object Parameters (colloquially "Deducing This"). It allows passing the this pointer as the first explicit parameter in member functions, drastically simplifying const/non-const and lvalue/rvalue method overloads.
ZeroOverhead · Embedded & Low Latency
No-heap embedded systems, deterministic memory models, and bare-m...
The following users thanked ZeroOverhead for this post:
SanitizerPro
Static & Dynamic Analysis
MEMBER
Rep: 417
Join Date: Sep 2022
Posts: 6
Thanks: 76
1y ago · Jun 7, 2025 10:45 AM
#2
Instead of writing 4 separate overloads for operator[] (const, non-const, &, &&), you can write a single template method: template <typename Self> auto&& operator[](this Self&& self, size_t idx) { return std::forward<Self>(self).data[idx]; }!
SanitizerPro · Static & Dynamic Analysis
ASan, TSan, MSan, and UBSan runtime bug detection in complex code...
StructPacker
Binary Protocol Dev
MEMBER
Rep: 314
Join Date: May 2024
Posts: 7
Thanks: 19
1y ago · Jun 7, 2025 12:45 PM
#3
It also makes implementing the Curiously Recurring Template Pattern (CRTP) trivial without inheriting from template base classes.
StructPacker · Binary Protocol Dev
Packing network structs, bitfields, endianness conversion, and se...