General Utility Library for C++17 25.4.1
Classes | Functions
gul17/type_name.h

Detailed Description

Generating human-readable descriptions for types.

Classes

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

Functions

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

Function Documentation

◆ type_name()

template<class T >
constexpr std::string_view gul17::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 " << gul17::type_name<decltype(literal)>() << '\n';
auto constexpr bit_set(unsigned bit) noexcept -> ReturnT
Set a bit in an integral type.
Definition bit_manip.h:121
Template Parameters
TType that shall be described
Returns
a string view that describes the type of the template parameter

References gul17::bit_set().