mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: improve HashTable iterator access and management
- provide key_iterator/const_key_iterator for all hashes,
reuse directly for HashSet as iterator/const_iterator, respectively.
- additional keys() method for HashTable that returns a wrapped to
a pair of begin/end const_iterators with additional size/empty
information that allows these to be used directly by anything else
expecting things with begin/end/size. Unfortunately does not yet
work with std::distance().
Example,
for (auto& k : labelHashTable.keys())
{
...
}
This commit is contained in:
3
applications/test/cplusplus1/Make/files
Normal file
3
applications/test/cplusplus1/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-cpluplus1.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-cpluplus1
|
||||
2
applications/test/cplusplus1/Make/options
Normal file
2
applications/test/cplusplus1/Make/options
Normal file
@ -0,0 +1,2 @@
|
||||
/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */
|
||||
/* EXE_LIBS = -lfiniteVolume */
|
||||
88
applications/test/cplusplus1/Test-cpluplus1.C
Normal file
88
applications/test/cplusplus1/Test-cpluplus1.C
Normal file
@ -0,0 +1,88 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Test miscellaneous C++ templates/functionality.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "string.H"
|
||||
#include "IOstreams.H"
|
||||
#include "UList.H"
|
||||
#include "HashSet.H"
|
||||
|
||||
#include <typeinfo>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// Macros to stringify macro contents.
|
||||
#define STRINGIFY(content) #content
|
||||
#define STRING_QUOTE(input) STRINGIFY(input)
|
||||
|
||||
#define PRINT_TYPEID(arg) \
|
||||
Info<< typeid(arg).name() << " <= typeid of " << STRING_QUOTE(arg) << nl
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< "various declaration types" << nl << nl;
|
||||
|
||||
PRINT_TYPEID(label);
|
||||
PRINT_TYPEID(decltype(UList<label>::value_type()));
|
||||
PRINT_TYPEID(decltype(std::declval<UList<label>>().cbegin()));
|
||||
PRINT_TYPEID(decltype(*(std::declval<UList<label>>().cbegin())));
|
||||
Info<< nl;
|
||||
|
||||
PRINT_TYPEID(decltype(HashTable<label>::key_type()));
|
||||
PRINT_TYPEID(decltype(HashTable<label>::value_type()));
|
||||
// Not yet: PRINT_TYPEID(decltype(HashTable<label>::mapped_type()));
|
||||
PRINT_TYPEID(decltype(std::declval<HashTable<label>>().begin()));
|
||||
PRINT_TYPEID(decltype(std::declval<const HashTable<label>>().begin()));
|
||||
PRINT_TYPEID(decltype(*(std::declval<HashTable<label>>().begin())));
|
||||
PRINT_TYPEID(decltype(*(std::declval<const HashTable<label>>().begin())));
|
||||
|
||||
PRINT_TYPEID(decltype(std::declval<const HashTable<label>>().keys()));
|
||||
Info<< nl;
|
||||
|
||||
PRINT_TYPEID(decltype(HashSet<label>::key_type()));
|
||||
PRINT_TYPEID(decltype(HashSet<label>::value_type()));
|
||||
// Not yet: PRINT_TYPEID(decltype(HashSet<label>::mapped_type()));
|
||||
PRINT_TYPEID(decltype(std::declval<HashSet<label>>().begin()));
|
||||
PRINT_TYPEID(decltype(std::declval<const HashSet<label>>().begin()));
|
||||
PRINT_TYPEID(decltype(*(std::declval<HashSet<label>>().begin())));
|
||||
PRINT_TYPEID(decltype(*(std::declval<const HashSet<label>>().begin())));
|
||||
Info<< nl;
|
||||
|
||||
Info << "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user