SpECTRE  v2024.09.29
Pretty Type

Pretty printing of types. More...

Namespaces

namespace  pretty_type
 Contains all functions that are part of PrettyType, used for printing types in a pretty manner.
 

Classes

struct  pretty_type::stl_templates
 A list of type traits to check if something is an STL member. More...
 

Typedefs

using pretty_type::basics_map = detail::TemplateMap_t< char, signed char, unsigned char, wchar_t, char16_t, char32_t, int, unsigned int, long, unsigned long, long long, unsigned long long, short, unsigned short, float, double, long double, bool, std::string >
 typelist of basic types that can be pretty printed More...
 

Functions

template<typename T , typename Map = basics_map, typename KnownTemplates = stl_templates>
std::string pretty_type::get_name ()
 Returns a string with the prettiest typename known for the type T. More...
 
template<typename T >
std::string pretty_type::get_runtime_type_name (const T &x)
 Returns a string with the prettiest typename known for the runtime type of x. More...
 
template<typename T >
std::string pretty_type::short_name ()
 Return the "short name" of a class, that is, the name without template parameters or scopes.
 
template<typename List >
std::string pretty_type::list_of_names ()
 Return a comma separated list of the pretty_type::name of every type in a tmpl::list. More...
 

Variables

template<typename... Types>
std::vector< std::stringpretty_type::vector_of_get_names (tmpl::list< Types... >)
 Return a vector of the pretty_type::get_name of every type in a tmpl::list.
 
template<typename T >
std::string pretty_type::name ()
 Return the result of the name() member of a class. If a class doesn't have a name() member, call pretty_type::short_name<T>() instead. More...
 
template<typename T >
std::string pretty_type::name (const T &)
 Return the result of the name() member of a class. If a class doesn't have a name() member, call pretty_type::short_name<T>() instead. More...
 

Detailed Description

Pretty printing of types.

Typedef Documentation

◆ basics_map

using pretty_type::basics_map = typedef detail::TemplateMap_t<char, signed char, unsigned char, wchar_t, char16_t, char32_t, int, unsigned int, long, unsigned long, long long, unsigned long long, short, unsigned short, float, double, long double, bool, std::string>

typelist of basic types that can be pretty printed

These are specializations of tt::Type<T>

Function Documentation

◆ get_name()

template<typename T , typename Map = basics_map, typename KnownTemplates = stl_templates>
std::string pretty_type::get_name ( )

Returns a string with the prettiest typename known for the type T.

Example usage: auto name = get_name<T>();

Template Parameters
Tthe type to print
Mapa tmpl::map of basic types (non-containers) and their Type<T> specializations that determine how to print the type name in a pretty form
KnownTemplatesstruct hold template alias tmpl::list of is_... that are known how to be printed pretty

Returns: std::string containing the typename

◆ get_runtime_type_name()

template<typename T >
std::string pretty_type::get_runtime_type_name ( const T &  x)

Returns a string with the prettiest typename known for the runtime type of x.

The result will generally not be as pretty as the result of get_name, but this function will report the derived type of a class when only given a base class reference, which get_type cannot do.

◆ list_of_names()

template<typename List >
std::string pretty_type::list_of_names ( )

Return a comma separated list of the pretty_type::name of every type in a tmpl::list.

Note
The tmpl::list must be flattened.

◆ name() [1/2]

template<typename T >
std::string pretty_type::name ( )

Return the result of the name() member of a class. If a class doesn't have a name() member, call pretty_type::short_name<T>() instead.

Warning
Do not use this inside the name() member of struct. This can lead to recursion as pretty_type::name<Tag>() will call the name() member of the struct.

◆ name() [2/2]

template<typename T >
std::string pretty_type::name ( const T &  )

Return the result of the name() member of a class. If a class doesn't have a name() member, call pretty_type::short_name<T>() instead.

Warning
Do not use this inside the name() member of struct. This can lead to recursion as pretty_type::name<Tag>() will call the name() member of the struct.