For the following code:
template <typename T>
auto fun() { return T{}; }
template <typename T>
T fun2() { return T{}; }
int fun3() { return 0; }
template <typename T>
void fun4(T) {}
int main()
{
fun<int>();
fun2<int>();
fun3();
fun4(3);
}
When using clang / GCC to compile, the output contains the following function signatures:
$ nm ./a.out | c++filt -t | grep fun
0000000000001206 W auto fun<int>()
0000000000001215 W int fun2<int>()
0000000000001169 T fun3()
0000000000001224 W void fun4<int>(int)
I know that for template function, the return type is included in the signature. However, I don't know why. Are there any usage to dump the return type into the function signature?
Thanks a lot!