/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, OCaml, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <iostream>
#include <typeinfo>
#include <cxxabi.h>
struct Simple { };
template <typename T>
const auto type_name() -> std::string
{
const auto prefix = std::string{"[with T = "};
const auto suffix = std::string{";"};
const auto function = std::string{__PRETTY_FUNCTION__};
const auto start = function.find(prefix) + prefix.size();
const auto end = function.rfind(suffix);
const auto result = function.substr(start, (end - start));
return result;
}
int main() {
std::cout << type_name<std::string>() << std::endl;
std::cout << type_name<Simple>() << std::endl;
}