I am playing with generic lambda in C++1y and I often confused by don\'t know what is the type of auto
variable/parameter. Is any good way to find it out?
Use GCC’s __cxa_demangle function:
std::string demangled(std::string const& sym) {
std::unique_ptr
name{abi::__cxa_demangle(sym.c_str(), nullptr, nullptr, nullptr), std::free};
return {name.get()};
}
auto f = [](auto && a, auto b) {
std::cout << demangled(typeid(decltype(a)).name()) << '\n';
std::cout << demangled(typeid(decltype(b)).name()) << '\n';
};