Warning, /include/Geant4/tools/safe_cast is written in an unsupported language. File is not indexed.
0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003
0004 #ifndef tools_safe_cast
0005 #define tools_safe_cast
0006
0007 #include "cid"
0008
0009 namespace tools {
0010
0011 template <class FROM,class TO>
0012 inline TO* safe_cast(FROM& a_o) {
0013 return (TO*)a_o.cast(TO::s_class());
0014 }
0015
0016 template <class FROM,class TO>
0017 inline const TO* safe_cast(const FROM& a_o) {
0018 return (const TO*)a_o.cast(TO::s_class());
0019 }
0020
0021 template <class FROM,class TO>
0022 inline TO* id_cast(FROM& a_o) {
0023 return (TO*)a_o.cast(TO::id_class());
0024 }
0025
0026 template <class FROM,class TO>
0027 inline const TO* id_cast(const FROM& a_o) {
0028 return (const TO*)a_o.cast(TO::id_class());
0029 }
0030
0031 }
0032
0033 #endif