Abbreviated Function Templates
C++20 function:
void myTemplateFunc(auto param) {}
is equivalent to pre C++20:
template <typename T> void myTemplateFunc(T param){}
1. Comparison
C++20 auto
:
main: push rbp mov rbp,rsp sub rsp,0x10 mov DWORD PTR [rbp-0x4],0x0 mov eax,DWORD PTR [rbp-0x4] mov edi,eax call 401126 <void myTemplateFunc<int>(int)> mov eax,0x0 leave ret void myTemplateFunc<int>(int): push rbp mov rbp,rsp mov DWORD PTR [rbp-0x4],edi nop pop rbp ret
Template function:
main: push rbp mov rbp,rsp sub rsp,0x10 mov DWORD PTR [rbp-0x4],0x0 mov eax,DWORD PTR [rbp-0x4] mov edi,eax call 401126 <void myTemplateFunc<int>(int)> mov eax,0x0 leave ret void myTemplateFunc<int>(int): push rbp mov rbp,rsp mov DWORD PTR [rbp-0x4],edi nop pop rbp ret