name() method from fcf::Type class
Class:
Package: fcfBasis
File: bits/PartType/TypeDefinition.hpp
Available from version: 1.0.1
Returns the human-readable name of the registered type.
This method provides access to the string representation of a type that has been registered in the fcf type system.
This name must be unique in the fcf type system.
Result
- A constant reference to the string containing the type's name.
Example: Basic usage of Type::name
#include <iostream>
#include <string>
// Define an implementation macro to include the implementation section in header files
#define FCF_BASIS_IMPLEMENTATION
#include <fcfBasis/basis.hpp>
// 1. Define a custom structure for demonstration
struct MyCustomStruct {
int id;
std::string name;
};
// 2. Register the type in the fcf system
// This is mandatory to allow the framework to recognize the type and provide metadata
FCF_TYPE_REGISTRATION (MyCustomStruct, "MyCustomStruct", 0);
int main() {
// 3. Access metadata for the custom type
// We use fcf::Type<T> to get a descriptor for MyCustomStruct
fcf::Type <MyCustomStruct> typeDescriptor;
// 4. Retrieve the name using the name() method
// The typeDescriptor.name () method returns the registered string
std::cout << "Registered type name: " << typeDescriptor.name () << std::endl;
// 5. Accessing metadata for a built-in type (e.g., int)
fcf::Type <int> intType;
std::cout << "Built-in type name: " << intType.name () << std::endl;
return 0;
}
Output:
Registered type name: MyCustomStruct
Built-in type name: int
VPSDime is an industry leading VPS hosting company that provides virtualized server services with high performance, availability and friendly support.