1 2 3 4 5 6 7 8 9 10 11 12
template <class T> struct Main { static Main tempFunction(){ return Main(); } }; int main() { Main<int> &mainReference = Main<int>::tempFunction(); }
1 2 3
In function 'int main()': Line 11: error: invalid initialization of non-const reference of type 'Main<int>&' from a temporary of type 'Main<int>' compilation terminated due to -Wfatal-errors.