diff --git a/src/OpenFOAM/memory/autoPtr/autoPtr.H b/src/OpenFOAM/memory/autoPtr/autoPtr.H index 748975b5cf33ed6e4bec94a6d8342fdde77e2e52..a8802f23a92ad193948fd9b18f427a563439500c 100644 --- a/src/OpenFOAM/memory/autoPtr/autoPtr.H +++ b/src/OpenFOAM/memory/autoPtr/autoPtr.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -104,6 +104,15 @@ public: inline void clear(); + // Access + + //- Return reference, without checking pointer validity. + inline T& refOrNull(); + + //- Return const reference, without checking pointer validity. + inline const T& refOrNull() const; + + // Member operators //- Return reference to the object data diff --git a/src/OpenFOAM/memory/autoPtr/autoPtrI.H b/src/OpenFOAM/memory/autoPtr/autoPtrI.H index ef199ca20c60ff4d2fde05e0f53af344091d38c1..7440bdce690c581572bc0a567e121be7c26defff 100644 --- a/src/OpenFOAM/memory/autoPtr/autoPtrI.H +++ b/src/OpenFOAM/memory/autoPtr/autoPtrI.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -129,6 +129,20 @@ inline void Foam::autoPtr<T>::clear() } +template<class T> +inline T& Foam::autoPtr<T>::refOrNull() +{ + return *ptr_; +} + + +template<class T> +inline const T& Foam::autoPtr<T>::refOrNull() const +{ + return *ptr_; +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class T>