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

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 260 of file G4AnyType.hh.

261{
262 const ValueType* result = any_cast<ValueType>(&operand);
263 if (!result) {
264 throw G4BadAnyCast();
265 }
266 return *result;
267}
ValueType * any_cast(G4AnyType *operand)
Definition G4AnyType.hh:246

◆ any_cast() [2/3]

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

Definition at line 254 of file G4AnyType.hh.

255{
256 return any_cast<ValueType>(const_cast<G4AnyType*>(operand));
257}

◆ any_cast() [3/3]

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

value

Definition at line 246 of file G4AnyType.hh.

247{
248 return operand && operand->TypeInfo() == typeid(ValueType)
249 ? &static_cast<G4AnyType::Ref<ValueType>*>(operand->fContent)->fRef
250 : nullptr;
251}
const std::type_info & TypeInfo() const
Definition G4AnyType.hh:113

Referenced by any_cast(), and any_cast().