STYLE: replace zero::null usage with zero

- the null output adapter was previously used for the HashTables API
  when HashSet actually stored key/value. Now that the node only
  contains the key, having suppressed output is redundant, as is the
  zero::null class (reduces clutter)

STYLE: replace one::minus dispatch in extendedEdgeMesh

GIT: remove Foam::nil typedef (deprecated since May-2017)
This commit is contained in:
Mark Olesen 2023-02-23 15:50:43 +01:00
parent cdcbd05587
commit b33b26ad34
12 changed files with 43 additions and 144 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,11 +25,11 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Some simple HashSet tests
\*---------------------------------------------------------------------------*/
#include "hashedWordList.H"
#include "nil.H"
#include "HashOps.H"
#include "HashSet.H"
#include "Map.H"
@ -123,7 +123,7 @@ int main(int argc, char *argv[])
{ "value3", 3 }
});
HashTable<nil> tableB;
HashTable<Foam::zero> tableB;
tableB.emplace("value4");
tableB.emplace("value5");
tableB.emplace("value6");
@ -185,7 +185,7 @@ int main(int argc, char *argv[])
Info<< wordHashSet(setA) << endl;
Info<< "create from HashTable<T>: ";
Info<< wordHashSet(tableA) << endl;
Info<< "create from HashTable<nil>: ";
Info<< "create from HashTable<zero>: ";
Info<< wordHashSet(tableB) << endl;
Info<< "create from Map<label>: ";

View File

@ -1,19 +0,0 @@
// Compatibility include. Superseded (MAY-2017) by Foam::zero::null
#ifndef FoamCompat_nil_H
#define FoamCompat_nil_H
#include "zero.H"
namespace Foam
{
//- Superseded (MAY-2017) by Foam::zero::null
// \deprecated(2017-05) - use Foam::zero::null instead
typedef zero::null nil;
}
#endif
// ************************************************************************* //

View File

@ -93,7 +93,7 @@ typedef HashSet<label, Hash<label>> labelHashSet;
template<class Key, class Hash=Foam::Hash<Key>>
class HashSet
:
public HashTable<zero::null, Key, Hash>
public HashTable<Foam::zero, Key, Hash>
{
// Private Member Functions
@ -113,7 +113,7 @@ public:
typedef HashSet<Key, Hash> this_type;
//- The template instance used for the parent HashTable
typedef HashTable<zero::null, Key, Hash> parent_type;
typedef HashTable<Foam::zero, Key, Hash> parent_type;
//- An iterator, returning reference to the key
using iterator = typename parent_type::key_iterator;

View File

@ -132,7 +132,7 @@ public:
//- with an additional linked-list entry for hash collisions
typedef typename std::conditional
<
std::is_same<zero::null, typename std::remove_cv<T>::type>::value,
std::is_same<Foam::zero, typename std::remove_cv<T>::type>::value,
Detail::HashTableSingle<Key>,
Detail::HashTablePair<Key, T>
>::type node_type;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -217,7 +217,7 @@ struct HashTableSingle
typedef K key_type;
//- Type of content (no content: placeholder)
typedef Foam::zero::null mapped_type;
typedef Foam::zero mapped_type;
//- Content storage type to the entry
typedef key_type value_type;
@ -271,22 +271,22 @@ struct HashTableSingle
return key_;
}
//- Const access to the (dummy) mapped value
//- Const access to the (dummy) mapped value (for API only)
const mapped_type& cval() const noexcept
{
return Foam::zero::null::dummy;
return Foam::zero::dummy;
}
//- Const access to the (dummy) mapped value
//- Const access to the (dummy) mapped value (for API only)
const mapped_type& val() const noexcept
{
return Foam::zero::null::dummy;
return Foam::zero::dummy;
}
//- Non-const access to the (dummy) mapped value
//- Non-const access to the (dummy) mapped value (for API only)
mapped_type& val() noexcept
{
return Foam::zero::null::dummy;
return Foam::zero::dummy;
}

View File

@ -90,7 +90,7 @@ public:
class noOp
:
public uniformOp<zero::null>
public uniformOp<Foam::zero>
{
public:
@ -106,9 +106,9 @@ public:
noOp() = default;
//- Construct from base
noOp(const uniformOp<zero::null>& op)
noOp(const uniformOp<Foam::zero>& op)
:
uniformOp<zero::null>(op)
uniformOp<Foam::zero>(op)
{}
@ -135,7 +135,7 @@ public:
class areaOp
:
public uniformOp<zero::null>
public uniformOp<Foam::zero>
{
public:
@ -151,9 +151,9 @@ public:
areaOp() = default;
//- Construct from base
areaOp(const uniformOp<zero::null>& op)
areaOp(const uniformOp<Foam::zero>& op)
:
uniformOp<zero::null>(op)
uniformOp<Foam::zero>(op)
{}
@ -179,7 +179,7 @@ public:
class volumeOp
:
public uniformOp<zero::null>
public uniformOp<Foam::zero>
{
public:
@ -195,9 +195,9 @@ public:
volumeOp() = default;
//- Construct from base
volumeOp(const uniformOp<zero::null>& op)
volumeOp(const uniformOp<Foam::zero>& op)
:
uniformOp<zero::null>(op)
uniformOp<Foam::zero>(op)
{}
@ -310,7 +310,7 @@ public:
template<unsigned N>
class listOp
:
public uniformOp<zero::null>
public uniformOp<Foam::zero>
{
public:
@ -350,9 +350,9 @@ public:
listOp() = default;
//- Construct from base
listOp(const uniformOp<zero::null>& op)
listOp(const uniformOp<Foam::zero>& op)
:
uniformOp<zero::null>(op)
uniformOp<Foam::zero>(op)
{}

View File

@ -141,7 +141,7 @@ public:
//- Swallow assignment (cf, std::ignore)
template<class T>
const NullObject& operator=(const T&) const
const NullObject& operator=(const T&) const noexcept
{
return *this;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -65,9 +65,6 @@ public:
//- The value type
typedef one value_type;
// Forward Declarations
class minus;
//- Default construct
constexpr one() noexcept {}
@ -101,53 +98,6 @@ public:
};
/*---------------------------------------------------------------------------*\
Class one::minus Declaration
\*---------------------------------------------------------------------------*/
//- A class representing the concept of -1.
// \note this class must never be derived from Foam::one, since this could
// potentially mask its behaviour.
class one::minus
{
public:
//- The value type
typedef minus value_type;
//- Default construct
constexpr minus() noexcept {}
//- Construct from Istream consumes no content.
explicit constexpr minus(Istream&) noexcept {}
//- Return -1 for label
constexpr operator label() const noexcept
{
return -1;
}
//- Return -1 for float
constexpr operator float() const noexcept
{
return -1;
}
//- Return -1 for double
constexpr operator double() const noexcept
{
return -1;
}
//- Component-wise or element-wise access returns minus one
one::minus operator[](const label) const noexcept
{
return one::minus{};
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Global one (1)
@ -161,12 +111,6 @@ inline constexpr Istream& operator>>(Istream& is, one&) noexcept
return is;
}
//- Read from Istream consumes no content.
inline constexpr Istream& operator>>(Istream& is, one::minus&) noexcept
{
return is;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,7 +32,7 @@ Note
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
Foam::zero::null Foam::zero::null::dummy;
Foam::zero Foam::zero::dummy;
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2022 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -66,8 +66,8 @@ public:
//- The value type
typedef zero value_type;
// Forward Declarations
class null;
//- A static instance, when modifiable reference is required by an API
static zero dummy;
//- Default construct
constexpr zero() noexcept {}
@ -105,30 +105,10 @@ public:
{
return zero{};
}
};
/*---------------------------------------------------------------------------*\
Class zero::null Declaration
\*---------------------------------------------------------------------------*/
//- A zero class with a null output adapter.
class zero::null
:
public zero
{
public:
typedef null value_type;
//- A static zero::null for dereferencing as a dummy element
static null dummy;
//- Default construct
constexpr null() noexcept {}
//- Construct from Istream consumes no content.
explicit constexpr null(Istream&) noexcept {}
// FUTURE?: Swallow assignment (as per std::ignore)
// template<class T>
// constexpr const zero& operator=(const T&) const { return *this; }
};
@ -145,12 +125,6 @@ inline constexpr Istream& operator>>(Istream& is, zero&) noexcept
return is;
}
//- Write to Ostream emits no content
inline constexpr Ostream& operator<<(Ostream& os, const zero::null&) noexcept
{
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2022 OpenCFD Ltd.
Copyright (C) 2015-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -400,7 +400,7 @@ Foam::extendedEdgeMesh::extendedEdgeMesh()
{}
Foam::extendedEdgeMesh::extendedEdgeMesh(class one::minus)
Foam::extendedEdgeMesh::extendedEdgeMesh(std::nullptr_t)
:
edgeMesh(),
concaveStart_(-1),
@ -486,7 +486,7 @@ Foam::extendedEdgeMesh::extendedEdgeMesh
const boolList& surfBaffleRegions
)
:
extendedEdgeMesh(one::minus{})
extendedEdgeMesh(nullptr)
{
// Extract and reorder the data from surfaceFeatures
const triSurface& surf = sFeat.surface();
@ -549,7 +549,7 @@ Foam::extendedEdgeMesh::extendedEdgeMesh
const labelUList& featurePoints
)
:
extendedEdgeMesh(one::minus{})
extendedEdgeMesh(nullptr)
{
sortPointsAndEdges
(

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -205,7 +205,7 @@ protected:
// Protected Constructors
//- Construct null, initializing start indices with -1
explicit extendedEdgeMesh(class one::minus);
explicit extendedEdgeMesh(std::nullptr_t);
// Protected Member Functions