![]() |
ATLAS Offline Software
|
Find the class ID of a type, without triggering an error if it isn't defined. More...
Go to the source code of this file.
Namespaces | |
| namespace | SG |
| Forward declaration. | |
Functions | |
| template<class T> | |
| constexpr CLID | SG::safe_clid () |
| Return the class ID of T, or CLID_NULL if it doesn't have one. | |
Find the class ID of a type, without triggering an error if it isn't defined.
The general interface for finding the class ID for some type T is to use ClassID_traits<T>::ID(). However, if no class ID has been defined for T, this will result in a compilation error. In some cases, where the class ID can be considered optional, this can severely restrict the applicability of generic code.
This header provides SG::safe_clid<T>(), which should return the class ID of T, or CLID_NULL if T does not have a defined class ID (without causing an error).
The implementation relies on the fact that when the class ID traits class gets specialized for a specific class ID, it defines has_classID_tag. The CLASS_DEF macro makes this definition, but if you specialize ClassID_traits yourself, you must remember to include has_classID_tag, or this function won't work.
Definition in file safe_clid.h.