COMP: HashTable: make end() iterator a reference to a static.

Weird one. Reported crash with gcc452 with end() iterator returning a copy.
The end() iterator returned was not initialised. No idea why & could not
repeat.
This commit is contained in:
mattijs
2011-03-08 10:56:30 +00:00
parent 6c52aacc57
commit b50eb38937
2 changed files with 11 additions and 6 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -97,16 +97,18 @@ struct HashTableCore
{} {}
}; };
static const iteratorEnd endIter;
//- iteratorEnd set to beyond the end of any HashTable //- iteratorEnd set to beyond the end of any HashTable
inline static iteratorEnd cend() inline static const iteratorEnd& cend()
{ {
return iteratorEnd(); return endIter;
} }
//- iteratorEnd set to beyond the end of any HashTable //- iteratorEnd set to beyond the end of any HashTable
inline static iteratorEnd end() inline static const iteratorEnd& end()
{ {
return iteratorEnd(); return endIter;
} }
}; };

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -37,6 +37,9 @@ const Foam::label Foam::HashTableCore::maxTableSize
) )
); );
const Foam::HashTableCore::iteratorEnd Foam::HashTableCore::endIter;
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::label Foam::HashTableCore::canonicalSize(const label size) Foam::label Foam::HashTableCore::canonicalSize(const label size)