boost::openmethod::policies::named_static_rtti

Implementation of the rtti policy that identifies classes by name.

Synopsis

Declared in <boost/openmethod/policies/named_static_rtti.hpp>

struct named_static_rtti
    : rtti

Description

named_static_rtti is a static_rtti that works across modules. It categorizes all types as non‐polymorphic, and its type ids are addresses that differ from one module to the next, like those of static_rtti. In addition, type_index maps them to the name of the class, as the compiler prints it, so the registry merges the copies of a class coming from different modules.

All the modules must be built with the same compiler, because the names must be spelled the same way. Dispatch does not use names at all. They are read before main, once per class in each module, as the class registers itself, and compared once, by initialize.

A class that has internal linkage, or none, is not shared: it is identified by its type_id, as with static_rtti. This covers the classes defined in an anonymous namespace, local classes, lambdas, unnamed classes, and the templates instantiated with any of these. With C++26 reflection, the policy asks the compiler which classes they are. Otherwise, it recognizes them from the marks that the compiler leaves in their names.

Clang and MSVC leave no mark in the name of a local class. Clang prints it unqualified, and MSVC prints it as if the function were a namespace (main::Local). Without reflection, two local classes that print the same name are taken for the same class, and so is a local class that prints the same name as a class at namespace scope. So is a class template instantiated with an entity that has internal linkage, such as the address of a static variable, with all compilers.

Base Classes

Name

Description

rtti

Policy for manipulating type information.

Types

Name

Description

fn

A RttiFn metafunction.

See Also

Created with MrDocs