ATLAS Offline Software
Namespaces | Functions
safe_clid.h File Reference

Find the class ID of a type, without triggering an error if it isn't defined. More...

#include "GaudiKernel/ClassID.h"
#include "AthenaKernel/tools/safe_clid.icc"
Include dependency graph for safe_clid.h:

Go to the source code of this file.

Namespaces

 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. More...
 

Detailed Description

Find the class ID of a type, without triggering an error if it isn't defined.

Author
scott snyder
Date
Nov 2005 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.