typeInfo: Added dynamicCastNull and refCastNull

These functions dynamic cast a reference to a type, and return a null
object reference if the cast fails. The standard dynamicCast and refCast
functions, by contrast, throw an error if the cast fails.
This commit is contained in:
Will Bainbridge
2024-04-05 14:18:20 +01:00
parent 1c6d785c1c
commit c11a2415d2
3 changed files with 42 additions and 5 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2014-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2014-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -72,6 +72,10 @@ extern const NullObject* nullObjectPtr;
template<class T>
inline const T& NullObjectRef();
//- Return non-const reference to the nullObject of type T
template<class T>
inline T& NullObjectNonConstRef();
//- Return const pointer to the nullObject of type T
template<class T>
inline const T* NullObjectConstPtr();