#include <string>
#include <typeinfo>
#ifdef __GNUG__
#include <cxxabi.h>
#include <cstdlib>
#include <memory>
template< typename T > std::string type_name()
{
int status ;
std::unique_ptr< char[], decltype(&std::free) > buffer(
__cxxabiv1::__cxa_demangle( typeid(T).name(), nullptr, 0, &status ), &std::free ) ;
return status==0 ? buffer.get() : "__cxa_demangle error" ;
}
#else // !defined __GNUG__
template< typename T > std::string type_name() { return typeid(T).name() ; }
#endif //__GNUG__
template< typename T > std::string type_name( const T& ) { return type_name<T>() ; }
#define print_type_name(var) ( std::cout << #var << " is of type " << type_name(var) << "\n\n" )
#include <iostream>
int main()
{
int array2D[3][3] = { { 1, 5, 6 }, { 45, 65, 65}, { 78, 10, 99 } } ;
auto ptr = array2D+1 ;
print_type_name( ptr ) ; // ptr is of type int (*) [3]
print_type_name( *ptr ) ; // *ptr is of type int [3]
}
I2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPHR5cGVpbmZvPgoKI2lmZGVmIF9fR05VR19fCgogICAgI2luY2x1ZGUgPGN4eGFiaS5oPgogICAgI2luY2x1ZGUgPGNzdGRsaWI+CiAgICAjaW5jbHVkZSA8bWVtb3J5PgoKICAgIHRlbXBsYXRlPCB0eXBlbmFtZSBUID4gc3RkOjpzdHJpbmcgdHlwZV9uYW1lKCkKICAgIHsKICAgICAgICBpbnQgc3RhdHVzIDsKICAgICAgICBzdGQ6OnVuaXF1ZV9wdHI8IGNoYXJbXSwgZGVjbHR5cGUoJnN0ZDo6ZnJlZSkgPiBidWZmZXIoCiAgICAgICAgICAgIF9fY3h4YWJpdjE6Ol9fY3hhX2RlbWFuZ2xlKCB0eXBlaWQoVCkubmFtZSgpLCBudWxscHRyLCAwLCAmc3RhdHVzICksICZzdGQ6OmZyZWUgKSA7CiAgICAgICAgcmV0dXJuIHN0YXR1cz09MCA/IGJ1ZmZlci5nZXQoKSA6ICJfX2N4YV9kZW1hbmdsZSBlcnJvciIgOwogICAgfQoKI2Vsc2UgLy8gIWRlZmluZWQg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