#include <iostream>
using namespace std;
int main() {
auto anonTemplate = []{struct{ template <typename T> void foo() { cout << "default\n"; } template <> void foo<char>() { cout << "specialized\n"; } } result; return result; }();
anonTemplate.foo<int>();
anonTemplate.foo<char>();
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwogCmludCBtYWluKCkgewoJYXV0byBhbm9uVGVtcGxhdGUgPSBbXXtzdHJ1Y3R7IHRlbXBsYXRlIDx0eXBlbmFtZSBUPiB2b2lkIGZvbygpIHsgY291dCA8PCAiZGVmYXVsdFxuIjsgfSB0ZW1wbGF0ZSA8PiB2b2lkIGZvbzxjaGFyPigpIHsgY291dCA8PCAic3BlY2lhbGl6ZWRcbiI7IH0gfSByZXN1bHQ7IHJldHVybiByZXN1bHQ7IH0oKTsKIAoJYW5vblRlbXBsYXRlLmZvbzxpbnQ+KCk7Cglhbm9uVGVtcGxhdGUuZm9vPGNoYXI+KCk7Cn0=
prog.cpp: In lambda function:
prog.cpp:5:33: error: invalid declaration of member template in local class
auto anonTemplate = []{struct{ template <typename T> void foo() { cout << "default\n"; } template <> void foo<char>() { cout << "specialized\n"; } } result; return result; }();
^
prog.cpp:5:101: error: explicit specialization in non-namespace scope 'struct main()::<lambda()>::<anonymous>'
auto anonTemplate = []{struct{ template <typename T> void foo() { cout << "default\n"; } template <> void foo<char>() { cout << "specialized\n"; } } result; return result; }();
^
prog.cpp:5:108: error: variable or field 'foo' declared void
auto anonTemplate = []{struct{ template <typename T> void foo() { cout << "default\n"; } template <> void foo<char>() { cout << "specialized\n"; } } result; return result; }();
^
prog.cpp:5:108: error: expected ';' at end of member declaration
prog.cpp:5:111: error: expected unqualified-id before '<' token
auto anonTemplate = []{struct{ template <typename T> void foo() { cout << "default\n"; } template <> void foo<char>() { cout << "specialized\n"; } } result; return result; }();
^
prog.cpp: In function 'int main()':
prog.cpp:7:15: error: 'struct main()::<lambda()>::<anonymous>' has no member named 'foo'
anonTemplate.foo<int>();
^
prog.cpp:7:19: error: expected primary-expression before 'int'
anonTemplate.foo<int>();
^
prog.cpp:8:15: error: 'struct main()::<lambda()>::<anonymous>' has no member named 'foo'
anonTemplate.foo<char>();
^
prog.cpp:8:19: error: expected primary-expression before 'char'
anonTemplate.foo<char>();
^