Hasty Briefsbeta

Bilingual

Spelling the type of a "self" parameter with Reflection

2 days ago
  • C++23 explicit object parameter syntax using 'this' keyword requires repetitive class name spelling.
  • C++26 reflection via std::meta::current_class() allows a 'using Self' alias to eliminate boilerplate.
  • A template alias Self<> with defaulted reflection argument enables factoring out boilerplate to top level.
  • The reflection-based approach passes 'self' by value, potentially avoiding memory load through 'this' pointer.
  • Self<> can also shorten special member function declarations like copy constructors and assignment operators.