Type name as a string
// __PRETTY_FUNCTION__ means "$FUNCTION_SIGNATURE [with T = $TYPE]".


When you call type_name_finder(), the only part that changes in __PRETTY_FUNCTION__ is $TYPE. We can use this information to strip the static decoration surrounding that type.

template &lt;typename T&gt;
static constexpr auto type_name_finder() {
    std::string_view name, prefix, suffix;

#if defined(__clang__)
    name = __PRETTY_FUNCTION__;
    prefix = "auto type_name_finder() [T = ";
    suffix = "]";
#elif defined(__GNUC__)
    name = __PRETTY_FUNCTION__;
    prefix = "constexpr auto type_name_finder() [with T = ";
    suffix = "]";
#endif

    name.remove_prefix(prefix.size());
    name.remove_suffix(suffix.size());
    return name;
}