www.mooseframework.org
Functions
CastUniquePointer.h File Reference

Go to the source code of this file.

Functions

template<typename T_DEST , typename T_SRC , typename T_DELETER >
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast (std::unique_ptr< T_SRC, T_DELETER > &src)
 These are reworked from https://stackoverflow.com/a/11003103. More...
 
template<typename T_DEST , typename T_SRC >
std::unique_ptr< T_DEST > dynamic_pointer_cast (std::unique_ptr< T_SRC > &src)
 

Function Documentation

◆ dynamic_pointer_cast() [1/2]

template<typename T_DEST , typename T_SRC , typename T_DELETER >
std::unique_ptr<T_DEST, T_DELETER> dynamic_pointer_cast ( std::unique_ptr< T_SRC, T_DELETER > &  src)

These are reworked from https://stackoverflow.com/a/11003103.

New GitHub Repo here: https://github.com/friedmud/unique_ptr_cast

Definition at line 22 of file CastUniquePointer.h.

Referenced by CreateExecutionerAction::act(), CreateProblemDefaultAction::act(), AddExternalAuxVariableAction::act(), ActionWarehouse::addActionBlock(), NonlinearSystemBase::addBoundaryCondition(), NonlinearSystemBase::addDamper(), FEProblemBase::addIndicator(), NonlinearSystemBase::addKernel(), FEProblemBase::addMultiApp(), ConstraintWarehouse::addObject(), MooseObjectWarehouseBase< Indicator >::addObject(), MooseObjectWarehouse< Indicator >::addObject(), ExecuteMooseObjectWarehouse< Transfer >::addObjectMask(), FEProblemBase::addTransfer(), FEProblemBase::addUserObject(), DerivativeParsedMaterialHelper::assembleDerivatives(), NonlinearEigenSystem::checkIntegrity(), FEProblemBase::checkNonlocalCoupling(), ComputeFullJacobianThread::computeFaceJacobian(), ComputeJacobianThread::computeFaceJacobian(), ComputeFullJacobianThread::computeJacobian(), ComputeJacobianThread::computeJacobian(), ComputeMortarFunctor< compute_stage >::ComputeMortarFunctor(), Factory::create(), BreakMeshByBlockGenerator::generate(), CartesianMeshGenerator::generate(), TransformGenerator::generate(), SideSetsBetweenSubdomainsGenerator::generate(), SubdomainIDGenerator::generate(), ElementSubdomainIDGenerator::generate(), MeshSideSetGenerator::generate(), AnnularMeshGenerator::generate(), RenameBlockGenerator::generate(), BreakBoundaryOnSubdomainGenerator::generate(), RenameBoundaryGenerator::generate(), LowerDBlockFromSidesetGenerator::generate(), SideSetsFromNormalsGenerator::generate(), SideSetsFromPointsGenerator::generate(), FileMeshGenerator::generate(), ConcentricCircleMeshGenerator::generate(), SmoothMeshGenerator::generate(), ElementGenerator::generate(), TiledMeshGenerator::generate(), ExtraNodesetGenerator::generate(), GeneratedMeshGenerator::generate(), ImageSubdomainGenerator::generate(), ParsedSubdomainMeshGenerator::generate(), SideSetsFromBoundingBoxGenerator::generate(), ImageMeshGenerator::generate(), MeshCollectionGenerator::generate(), MeshExtruderGenerator::generate(), AllSideSetsByNormalsGenerator::generate(), StackGenerator::generate(), CombinerGenerator::generate(), StitchedMeshGenerator::generate(), SpiralAnnularMeshGenerator::generate(), OrientedSubdomainBoundingBoxGenerator::generate(), RinglebMeshGenerator::generate(), ParsedGenerateSideset::generate(), ElementDeletionGeneratorBase::generate(), SideSetsAroundSubdomainGenerator::generate(), SubdomainBoundingBoxGenerator::generate(), PatternedMeshGenerator::generate(), BoundingBoxNodeSetGenerator::generate(), ActionWarehouse::getAction(), ActionWarehouse::getActions(), FEProblemBase::getNonlinearSystem(), ActionWarehouse::problem(), NonlinearSystem::setupFiniteDifferencedPreconditioner(), and Parser::walkRaw().

23 {
24  if (!src)
25  return std::unique_ptr<T_DEST, T_DELETER>(nullptr);
26 
27  T_DEST * dest_ptr = dynamic_cast<T_DEST *>(src.get());
28  if (!dest_ptr)
29  return std::unique_ptr<T_DEST, T_DELETER>(nullptr);
30 
31  std::unique_ptr<T_DEST, T_DELETER> dest_temp(dest_ptr, std::move(src.get_deleter()));
32 
33  src.release();
34 
35  return dest_temp;
36 }

◆ dynamic_pointer_cast() [2/2]

template<typename T_DEST , typename T_SRC >
std::unique_ptr<T_DEST> dynamic_pointer_cast ( std::unique_ptr< T_SRC > &  src)

Definition at line 40 of file CastUniquePointer.h.

41 {
42  if (!src)
43  return std::unique_ptr<T_DEST>(nullptr);
44 
45  T_DEST * dest_ptr = dynamic_cast<T_DEST *>(src.get());
46  if (!dest_ptr)
47  return std::unique_ptr<T_DEST>(nullptr);
48 
49  std::unique_ptr<T_DEST> dest_temp(dest_ptr);
50 
51  src.release();
52 
53  return dest_temp;
54 }