Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4AnyType.hh File Reference
#include <algorithm>
#include <typeinfo>
#include <iostream>
#include <sstream>

Go to the source code of this file.

Classes

class  G4AnyType
 
class  G4BadAnyCast
 

Namespaces

namespace  CLHEP
 

Functions

template<typename ValueType >
ValueType * any_cast (G4AnyType *operand)
 
template<typename ValueType >
const ValueType * any_cast (const G4AnyType *operand)
 
template<typename ValueType >
ValueType any_cast (const G4AnyType &operand)
 

Function Documentation

◆ any_cast() [1/3]

template<typename ValueType >
ValueType any_cast ( const G4AnyType operand)

value

Definition at line 210 of file G4AnyType.hh.

210 {
211 const ValueType* result = any_cast<ValueType>(&operand);
212 if (!result) {
213 throw G4BadAnyCast();
214 }
215 return *result;
216}

◆ any_cast() [2/3]

template<typename ValueType >
const ValueType * any_cast ( const G4AnyType operand)

value

Definition at line 206 of file G4AnyType.hh.

206 {
207 return any_cast<ValueType>(const_cast<G4AnyType*>(operand));
208}

◆ any_cast() [3/3]

template<typename ValueType >
ValueType * any_cast ( G4AnyType operand)

value

Definition at line 201 of file G4AnyType.hh.

201 {
202 return operand && operand->TypeInfo() == typeid(ValueType)
203 ? &static_cast<G4AnyType::Ref<ValueType>*>(operand->fContent)->fRef : 0;
204}
const std::type_info & TypeInfo() const
Definition: G4AnyType.hh:104