-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This is a cross-platform, C++23 reflection library that relies fully on modern C++ features, without using any pre/post build steps. Under the hood, it achieves that using a naming convention for specifying type traits, like:
struct MyType {
// A custom type name trait
public: static constexpr ::std::string_view CTTI_Name = "MyType";
// Usually, these are hidden behind a convenience macro, like:
LANGULUS_NAME() "MyType";
};
These types and constexpr variables never modify the type's size, and aim to be totally non-intrusive. None of these traits are mandatory, unless you need the type to behave in a specific way. This means, that you can reflect any type, and it will be inspected at compile-time for most stock type traits available in C++23.
Upon reflection (upon calling MetaOf<T>
), the type will be inspected using concepts and SFINAE to populate a global type-info instance (i.e. MetaData
), and registering it in a centralized location at runtime. This type-info can later be used to compare type-erased containers, perform serialization/deserialization, construction/destruction, and so on.
See the full catalogue of reflection options here.
Built-in types are handled by the library itself, and are reflected with imposed bases, so you can differentiate signed/unsigned integers at runtime by checking reflected bases.
The library is well tested against niche C++ specifics like virtual bases, aggregate types, compiler inconsistencies - providing a consistent and error-free representation of types.
The library has the capability of reflecting additional construction/assignment so-called intents
, that are implemented seamlessly on top of standard C++ move/copy semantics. Such intents are used in all Langulus libraries and plug-ins, see intents for more information about them.
Langulus::RTTI
also supports reflecting the same type from multiple libraries, elegantly checking versions and keeping track of conflicts at runtime. See reflecting from shared libraries.
The library also provides an extension to Langulus::CT concept library, with concepts related to type inspection and reflection.