AMTypeID  201909
String localization library
Static Public Member Functions | List of all members
AMCore::AMCETypeID< T > Class Template Reference

Constant expression id for types Simply, retrieve from given type it's name as a string, and integral id. More...

#include <AMCETypeID.h>

Static Public Member Functions

static constexpr const char * name ()
 Name of class. More...
 
static constexpr int nameLength ()
 Name length Zero at end is included. More...
 
static constexpr uint64_t hash_code ()
 Hash code 64-bit size. More...
 
static constexpr uint32_t hash_code32 ()
 Hash code 32-bit size. More...
 
static constexpr uint64_t id ()
 id Practically, id is some index in range in 0 to N. Main purpose is optimize switch statement, there compiler is able to make jump table, instead of comparing with many values. To ensure this functionality, program must be compiled with macro COLLECTING_DATA defined. Without it, this function returns 64-bit hash, so, can be used in cases of switch statement. More...
 
static constexpr uint32_t id32 ()
 lowest 32 bit of id() More...
 

Detailed Description

template<typename T>
class AMCore::AMCETypeID< T >

Constant expression id for types Simply, retrieve from given type it's name as a string, and integral id.

Member Function Documentation

◆ hash_code()

template<typename T >
static constexpr uint64_t AMCore::AMCETypeID< T >::hash_code ( )
inlinestaticconstexpr

Hash code 64-bit size.

Returns
hash

◆ hash_code32()

template<typename T >
static constexpr uint32_t AMCore::AMCETypeID< T >::hash_code32 ( )
inlinestaticconstexpr

Hash code 32-bit size.

Returns
hash

◆ id()

template<typename T >
static constexpr uint64_t AMCore::AMCETypeID< T >::id ( )
inlinestaticconstexpr

id Practically, id is some index in range in 0 to N. Main purpose is optimize switch statement, there compiler is able to make jump table, instead of comparing with many values. To ensure this functionality, program must be compiled with macro COLLECTING_DATA defined. Without it, this function returns 64-bit hash, so, can be used in cases of switch statement.

id is not constexpr if COLLECTING_DATA if defined. If you need constexpr, you may use hash_code function.

Returns
id 64-bit

◆ id32()

template<typename T >
static constexpr uint32_t AMCore::AMCETypeID< T >::id32 ( )
inlinestaticconstexpr

lowest 32 bit of id()

Returns
32-bit sized id

◆ name()

template<typename T >
static constexpr const char* AMCore::AMCETypeID< T >::name ( )
inlinestaticconstexpr

Name of class.

Returns
Zero ended string

◆ nameLength()

template<typename T >
static constexpr int AMCore::AMCETypeID< T >::nameLength ( )
inlinestaticconstexpr

Name length Zero at end is included.

Returns
length

The documentation for this class was generated from the following file: