#ifndef _TILE_BASE_DEMANGLE_H
#define _TILE_BASE_DEMANGLE_H

#pragma once

#include <string>
#include <typeinfo>
#include <utility>

namespace tile {

std::string Demangle(const char *s);

template<class T>
std::string
GetTypeName()
{
    return Demangle(typeid(T).name());
}

#if __GNUC__ >= 12
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnonnull-compare"
#endif

template<class T>
std::string
GetTypeName(T &&o)
{
    return Demangle(typeid(std::forward<T>(o)).name());
}

#if __GNUC__ >= 12
#pragma GCC diagnostic pop
#endif

}// namespace tile

#endif// _TILE_BASE_DEMANGLE_H
