VLink 2.0.0
A high-performance communication middleware
Loading...
Searching...
No Matches
vlink::NameDetector Namespace Reference

Compile-time type-name and enum-name detection utilities. More...

Functions

template<typename T>
constexpr bool is_support () noexcept
 Checks at compile time whether the nameof library can produce a type name for T.
template<typename T>
constexpr std::string_view get () noexcept
 Returns the unqualified compile-time name of type T as a std::string_view.
template<typename T>
std::string_view get_enum (T e) noexcept
 Returns the string representation of an enumeration value e.

Detailed Description

Compile-time type-name and enum-name detection utilities.

Function Documentation

◆ get()

template<typename T>
std::string_view vlink::NameDetector::get ( )
inlinenodiscardconstexprnoexcept

Returns the unqualified compile-time name of type T as a std::string_view.

On Windows, leading "struct " and "class " prefixes that MSVC may inject are stripped before returning. On other platforms the raw nameof::nameof_type<T>() result is returned.

The returned view points to static storage (lifetime of the program). It is used by the VLink plugin system to register interfaces by their type name rather than by a manually specified string.

Template Parameters
TThe type whose name is requested.
Returns
A constexpr std::string_view containing the type name.
Note
This function is constexpr on supported compilers. The result is identical whether evaluated at compile time or runtime.
Here is the caller graph for this function:

◆ get_enum()

template<typename T>
std::string_view vlink::NameDetector::get_enum ( T e)
inlinenodiscardnoexcept

Returns the string representation of an enumeration value e.

Wraps nameof::nameof_enum to obtain the enumerator name. Returns an empty std::string_view if the value is out of the known range.

Template Parameters
TThe enumeration type.
Parameters
eThe enumeration value to name.
Returns
A std::string_view containing the enumerator name, or an empty view if e is not a named enumerator.

◆ is_support()

template<typename T>
bool vlink::NameDetector::is_support ( )
inlinenodiscardconstexprnoexcept

Checks at compile time whether the nameof library can produce a type name for T.

Details.

Returns true when the underlying nameof::detail::nameof_type_supported trait evaluates to true for T. When this returns false, calling get<T>() may produce an empty or implementation-defined string.

Template Parameters
TThe type to check.
Returns
true if type-name detection is supported for T.
Here is the caller graph for this function: