g4tools  5.4.0
safe_cast
Go to the documentation of this file.
1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
2 // See the file tools.license for terms.
3 
4 #ifndef tools_safe_cast
5 #define tools_safe_cast
6 
7 #include "cid"
8 
9 namespace tools {
10 
11 template <class FROM,class TO>
12 inline TO* safe_cast(FROM& a_o) {
13  return (TO*)a_o.cast(TO::s_class());
14 }
15 
16 template <class FROM,class TO>
17 inline const TO* safe_cast(const FROM& a_o) {
18  return (const TO*)a_o.cast(TO::s_class());
19 }
20 
21 template <class FROM,class TO>
22 inline TO* id_cast(FROM& a_o) {
23  return (TO*)a_o.cast(TO::id_class());
24 }
25 
26 template <class FROM,class TO>
27 inline const TO* id_cast(const FROM& a_o) {
28  return (const TO*)a_o.cast(TO::id_class());
29 }
30 
31 }
32 
33 #endif
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::id_cast
TO * id_cast(FROM &a_o)
Definition: safe_cast:22
tools::safe_cast
TO * safe_cast(FROM &a_o)
Definition: safe_cast:12
cid