Pass this by value uwu
Pass this by value Since we can define the qualifiers of the now-explicit object parameter, we can choose to take it by value rather than by reference. For small objects, this can give us better runtime performance. In case you’re not familiar with how this affects code generation, here’s an example. Say we have this code, using regular old implicit object parameters: struct just_a_little_guy { int how_smol; int uwu(); }; int main() { just_a_little_guy tiny_tim{42}; return tiny_tim.uwu(); } MSVC generates the following assembly: sub rsp, 40 lea rcx, QWORD PTR tiny_tim$[rsp] mov DWORD PTR tiny_tim$[rsp], 42 call int just_a_little_guy::uwu(void) add rsp, 40 ret 0
A programming documentation screenshot explains passing a small C++ object by value and shows the generated assembly. The joke is the deliberately cute class and method names, “just_a_little_guy,” “how_smol,” “tiny_tim,” and “uwu,” which turn a technical example into an adorable reaction to tiny code objects. EN: A programming documentation screenshot explains passing a small C++ object by value and shows the generated assembly. The joke is the deliberately cute class and method names, “just_a_little_guy,” “how_smol,” “tiny_tim,” and “uwu,” which turn a technical example into an adorable reaction to tiny code objects.
- @gentoomemes / 2308 2023-02-08
- Type
- image
- Size
- 800×730 · 77.0 KiB
- Mood
- cute, nerdy
- Language
- en
- Added