General Utility Library for C++14  2.12
Classes | Functions
gul14/type_name.h

Detailed Description

Generating human-readable descriptions for types.

Classes

class  gul14::FailToInstantiate< T >
 A helper class to debug types. More...
 

Functions

template<class T >
constexpr string_view gul14::type_name ()
 Generate a human readable string describing a type. More...
 

Function Documentation

◆ type_name()

template<class T >
constexpr string_view gul14::type_name ( )
constexpr

Generate a human readable string describing a type.

Cuts out the most relevant part of __PRETTY_FUNCTION__ of itself, ignoring all the stuff that contains information on the function itself, leaving just the description of the template parameter.

Note: __FUNCSIG__ with MSVC.

This function can only be constexpr if __PRETTY_FUNCTION__ is constexpr. This function is not constexpr with MSVC because of language limits.

Use like this:

auto& literal = "test";
std::cout << "The type is " << gul14::type_name<decltype(literal)>() << '\n';
Template Parameters
TType that shall be described
Returns
a string view that describes the type of the template parameter