FCF 2.0 development in progress...
> > > >
[News] [C++ Libraries API] [C++ Downloads] [Donate to the project] [Contacts]

typedef fcf::TypeIndex

Type: fcf::TypeIndex

Definition: typedef unsigned int TypeIndex;

Package: fcfBasis

File: bits/PartType/TypeIndex.hpp

Available from version: 1.0.1

Unique integer identifier for a registered type

This integer type is used throughout the framework to represent and distinguish between different types in the runtime type system. It can also encode additional information such as constness, reference qualifiers, and pointer levels.

Example:

#include <iostream> #include <string> // Define an implementation macro to include the implementation section in header files #define FCF_BASIS_IMPLEMENTATION #include <fcfBasis/basis.hpp> int main() { // Accessing metadata for a built-in type // We use fcf::Type<T> to get a description for std::string { fcf::TypeIndex typeIndex = fcf::Type<std::string>().index(); const std::string& typeName = fcf::Type<std::string>().name(); std::cout << "1. "<< typeName << std::endl; std::cout << " Type index: 0x" << std::hex << typeIndex << std::dec << std::endl; } { fcf::TypeIndex typeIndex = fcf::Type<std::string*>().index(); const std::string& typeName = fcf::Type<std::string*>().name(); std::cout << "2. "<< typeName << std::endl; std::cout << " Type index: 0x" << std::hex << typeIndex << std::dec << std::endl; } { fcf::TypeIndex typeIndex = fcf::Type<std::string&>().index(); const std::string& typeName = fcf::Type<std::string&>().name(); std::cout << "3. "<< typeName << std::endl; std::cout << " Type index: 0x" << std::hex << typeIndex << std::dec << std::endl; } { fcf::TypeIndex typeIndex = fcf::Type<const std::string>().index(); const std::string& typeName = fcf::Type<const std::string>().name(); std::cout << "4. "<< typeName << std::endl; std::cout << " Type index: 0x" << std::hex << typeIndex << std::dec << std::endl; } { fcf::TypeIndex typeIndex = fcf::Type<const std::string&>().index(); const std::string& typeName = fcf::Type<const std::string&>().name(); std::cout << "5. "<< typeName << std::endl; std::cout << " Type index: 0x" << std::hex << typeIndex << std::dec << std::endl; } return 0; }

Output:

1. std::string Type index: 0x1e 2. std::string* Type index: 0x1000001e 3. std::string& Type index: 0x200001e 4. const std::string Type index: 0x800001e 5. const std::string& Type index: 0xa00001e