STYLE: ensure that emptyLabelList is known from List.H

- treat as a List constant without requiring inclusion of ListOps.H

- replace use of emptyList<label>() with emptyLabelList directly.
  The emptyList<T>() casting is disallowed with many modern compilers
  and now marked as deprecated (expect early removal).

- relocate labelList typedef to List.H for more general access.
  Similar reasoning to having labelUList defined in UList.H
This commit is contained in:
Mark Olesen
2018-08-01 21:27:46 +02:00
parent edb0d1dd97
commit d8c0167ea8
8 changed files with 26 additions and 13 deletions

View File

@ -2398,7 +2398,7 @@ const Foam::labelList& Foam::dynamicIndexedOctree<Type>::findIndices
return *(contents_[getContent(contentIndex)]);
}
return emptyList<label>();
return Foam::emptyLabelList;
}

View File

@ -2660,7 +2660,7 @@ const Foam::labelList& Foam::indexedOctree<Type>::findIndices
{
if (nodes_.empty())
{
return emptyList<label>();
return Foam::emptyLabelList;
}
labelBits index = findNode(0, sample);
@ -2675,7 +2675,7 @@ const Foam::labelList& Foam::indexedOctree<Type>::findIndices
return contents_[getContent(contentIndex)];
}
return emptyList<label>();
return Foam::emptyLabelList;
}

View File

@ -69,8 +69,12 @@ template<class T> class BiIndirectList;
template<class T> Istream& operator>>(Istream& is, List<T>& list);
// Commonly required list types
// Common list types
typedef List<char> charList;
typedef List<label> labelList;
//- A zero-sized list of labels
extern const labelList emptyLabelList;
/*---------------------------------------------------------------------------*\

View File

@ -26,7 +26,7 @@ License
#include "ListOps.H"
#include <numeric>
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Global Data Members * * * * * * * * * * * * * //
const Foam::labelList Foam::emptyLabelList;

View File

@ -54,10 +54,10 @@ SourceFiles
namespace Foam
{
extern const labelList emptyLabelList;
//- Return reference to zero-sized list. Compare to List::null() which returns
// null pointer cast as list reference.
//- Return reference to zero-sized list.
// Compare to List::null() which returns null pointer cast as list reference.
//
// \deprecated This cast is disallowed with many modern compilers (JUL-2018)
template<class Type>
static const List<Type>& emptyList()
{

View File

@ -47,6 +47,13 @@ SourceFiles
namespace Foam
{
// Forward declarations
template<class T> class SubList;
// Common list types
typedef SubList<label> labelSubList;
/*---------------------------------------------------------------------------*\
Class SubList Declaration
\*---------------------------------------------------------------------------*/

View File

@ -67,10 +67,11 @@ template<class T> class UList;
template<class T> Ostream& operator<<(Ostream&, const UList<T>&);
template<class T> Istream& operator>>(Istream&, UList<T>&);
// Commonly required list types
// Common list types
typedef UList<char> charUList;
typedef UList<label> labelUList;
/*---------------------------------------------------------------------------*\
Class UList Declaration
\*---------------------------------------------------------------------------*/

View File

@ -64,9 +64,10 @@ Description
namespace Foam
{
// NB: labelUList is defined in UList itself
typedef List<label> labelList;
typedef SubList<label> labelSubList;
// labelUList = defined in UList.H
// labelList = defined in List.H
// labelSubList = defined in SubList.H
typedef List<labelList> labelListList;
typedef List<labelListList> labelListListList;
}