Geant4 11.1.1
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>
#include "G4UIcommand.hh"

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)

Definition at line 273 of file G4AnyType.hh.

274{
275 const ValueType* result = any_cast<ValueType>(&operand);
276 if(!result)
277 {
278 throw G4BadAnyCast();
279 }
280 return *result;
281}

◆ any_cast() [2/3]

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

Definition at line 267 of file G4AnyType.hh.

268{
269 return any_cast<ValueType>(const_cast<G4AnyType*>(operand));
270}

◆ any_cast() [3/3]

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

value

Definition at line 259 of file G4AnyType.hh.

260{
261 return operand && operand->TypeInfo() == typeid(ValueType)
262 ? &static_cast<G4AnyType::Ref<ValueType>*>(operand->fContent)->fRef
263 : nullptr;
264}
const std::type_info & TypeInfo() const
Definition: G4AnyType.hh:115