From 9c74abb7d259febe9486f2197a301321bfa28031 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 8 Jan 2019 10:51:24 +0100 Subject: [PATCH] ENH: zero::null::dummy, when dereferencing and dummy assignment are needed --- src/OpenFOAM/global/global.Cver | 3 ++- src/OpenFOAM/primitives/zero/zero.C | 33 +++++++++++++++++++++++++++++ src/OpenFOAM/primitives/zero/zero.H | 4 ++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/OpenFOAM/primitives/zero/zero.C diff --git a/src/OpenFOAM/global/global.Cver b/src/OpenFOAM/global/global.Cver index 1f27a0f91b..508701d6d3 100644 --- a/src/OpenFOAM/global/global.Cver +++ b/src/OpenFOAM/global/global.Cver @@ -88,9 +88,10 @@ const std::string Foam::foamVersion::version #include "new.C" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Create the nullObject singleton +// The nullObject singleton and a dummy zero singleton #include "nullObject.C" +#include "zero.C" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Global IO streams diff --git a/src/OpenFOAM/primitives/zero/zero.C b/src/OpenFOAM/primitives/zero/zero.C new file mode 100644 index 0000000000..96552a0a4d --- /dev/null +++ b/src/OpenFOAM/primitives/zero/zero.C @@ -0,0 +1,33 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "zero.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +Foam::zero::null Foam::zero::null::dummy; + + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/zero/zero.H b/src/OpenFOAM/primitives/zero/zero.H index 0cc989c825..c74d9f9616 100644 --- a/src/OpenFOAM/primitives/zero/zero.H +++ b/src/OpenFOAM/primitives/zero/zero.H @@ -29,6 +29,7 @@ Description manipulating objects that are known to be 'zero' at compile-time. SourceFiles + zero.C zeroI.H \*---------------------------------------------------------------------------*/ @@ -105,6 +106,9 @@ class zero::null public: typedef null value_type; + //- A static zero::null for dereferencing as a dummy element + static null dummy; + //- Null constructible constexpr null() noexcept{}