Geant4 10.7.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>
#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 270 of file G4AnyType.hh.

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

◆ any_cast() [2/3]

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

Definition at line 264 of file G4AnyType.hh.

265{
266 return any_cast<ValueType>(const_cast<G4AnyType*>(operand));
267}

◆ any_cast() [3/3]

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

value

Definition at line 256 of file G4AnyType.hh.

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