boost::openmethod::policies::std_rtti::fn::type_index
Returns a key that identifies a class across modules.
Synopsis
Declared in <boost/openmethod/policies/std_rtti.hpp>
static
auto
type_index(type_id type);
Description
C++ does not guarantee that there is a single instance of std::type_info per type: a class used by several modules of a program typically has one per module. type_index maps a type_id to a key that compares equal for all the type ids of one class, which is what initialize uses to group the registrations coming from different modules. The key also tells apart two classes with the same name in different translation units, when they are defined in anonymous namespaces, or are unnamed classes or lambdas.
The type of the key is unspecified; it supports ==, < and std::hash. With MSVC, and with GCC and libstdc++, it is a std::type_index: their std::type_info equality compares names, except where the name of a class is shared by another one, in a different translation unit. Elsewhere it is not: libc++ compares the std::type_info objects of a class with hidden visibility by address, so the copies in different modules are unequal, and Clang does not mark the classes with internal linkage for libstdc++. The key is then the mangled name, plus the type_id if the mangled name shows an anonymous namespace, an unnamed class, or a lambda.
|
Two classes with the same name, local to |
Parameters
Name |
Description |
type |
A |
Created with MrDocs