diff --git a/applications/test/DLList/Test-DLList.C b/applications/test/DLList/Test-DLList.C index d370348982..8e653c4b20 100644 --- a/applications/test/DLList/Test-DLList.C +++ b/applications/test/DLList/Test-DLList.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -41,6 +41,8 @@ int main(int argc, char *argv[]) { DLList myList; + Info<< "DLList" << nl; + for (int i = 0; i<10; i++) { myList.append(1.3*i); @@ -49,9 +51,7 @@ int main(int argc, char *argv[]) myList.append(100.3); myList.append(500.3); - Info<< nl << "And again using STL iterator: " << nl << endl; - - forAllIter(DLList, myList, iter) + forAllConstIters(myList, iter) { Info<< "element:" << *iter << endl; } @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) Info<< nl << "And again using the same STL iterator: " << nl << endl; - forAllIter(DLList, myList, iter) + forAllIters(myList, iter) { Info<< "Removing " << myList.remove(iter) << endl; } @@ -68,13 +68,10 @@ int main(int argc, char *argv[]) myList.append(200.3); myList.append(100.3); - - Info<< nl << "And again using STL const_iterator: " << nl << endl; - - - forAllConstIter(DLList, myList, iter) + Info<< nl << "Using range-based for: " << nl << endl; + for (auto val : myList) { - Info<< "element:" << *iter << endl; + Info<< "element:" << val << endl; } Info<< nl << "Testing swapUp and swapDown: " << endl; @@ -84,9 +81,9 @@ int main(int argc, char *argv[]) myList.swapUp(myList.DLListBase::first()); myList.swapUp(myList.DLListBase::last()); - forAllIter(DLList, myList, iter) + for (auto val : myList) { - Info<< "element:" << *iter << endl; + Info<< "element:" << val << endl; } Info<< nl << "swapDown" << endl; @@ -94,12 +91,11 @@ int main(int argc, char *argv[]) myList.swapDown(myList.DLListBase::first()); myList.swapDown(myList.DLListBase::last()); - forAllIter(DLList, myList, iter) + for (auto val : myList) { - Info<< "element:" << *iter << endl; + Info<< "element:" << val << endl; } - Info<< nl << "Testing transfer: " << nl << nl << "original: " << myList << endl; diff --git a/applications/test/Dictionary/Test-Dictionary.C b/applications/test/Dictionary/Test-Dictionary.C index f48845a36f..251cb2f841 100644 --- a/applications/test/Dictionary/Test-Dictionary.C +++ b/applications/test/Dictionary/Test-Dictionary.C @@ -168,9 +168,24 @@ int main(int argc, char *argv[]) Info<< nl << "scalarDict2: " << endl; forAllConstIter(PtrDictionary, scalarDict2, iter) { + std::cout<< "iter: " << typeid(*iter).name() << '\n'; + Info<< "elem = " << *iter << endl; } + // FIXME: the deduction seems to be different here. + // - returns pointer (as perhaps actually expected) not the + // underlying value. + forAllConstIters(scalarDict2, iter) + { + std::cout<< "iter: " << typeid(*iter).name() << '\n'; + + Info<< "elem = " << *(*iter) << endl; + } + + std::cout<< "iter type: " + << typeid(stdFoam::begin(scalarDict2)).name() << '\n'; + scalarDict.transfer(scalarDict2); diff --git a/applications/test/HashTable/Test-hashTable.C b/applications/test/HashTable/Test-hashTable.C index dc2f70658e..391a5ee618 100644 --- a/applications/test/HashTable/Test-hashTable.C +++ b/applications/test/HashTable/Test-hashTable.C @@ -62,7 +62,7 @@ int main() Info<< "\ntable1 sortedToc: " << table1.sortedToc() << endl; table1.printInfo(Info) << "table1 [" << table1.size() << "] " << endl; - forAllConstIter(HashTable, table1, iter) + forAllConstIters(table1, iter) { Info<< iter.key() << " => " << iter() << nl; } @@ -106,7 +106,7 @@ int main() << "\ntable3" << table3 << nl; Info<< "\nerase table2 by iterator" << nl; - forAllIter(HashTable, table2, iter) + forAllIters(table2, iter) { Info<< "erasing " << iter.key() << " => " << iter.object() << " ... "; table2.erase(iter); diff --git a/applications/test/ISLList/Test-ISLList.C b/applications/test/ISLList/Test-ISLList.C index ef4fd6614d..38ba2a1424 100644 --- a/applications/test/ISLList/Test-ISLList.C +++ b/applications/test/ISLList/Test-ISLList.C @@ -78,7 +78,7 @@ int main(int argc, char *argv[]) Info<< nl << "And again using STL iterator: " << nl << endl; - forAllIter(SLList, myList, iter) + forAllIters(myList, iter) { Info<< "element:" << *iter << endl; } @@ -87,7 +87,7 @@ int main(int argc, char *argv[]) const ISLList& const_myList = myList; - forAllConstIter(SLList, const_myList, iter) + forAllConstIters(const_myList, iter) { Info<< "element:" << *iter << endl; } diff --git a/applications/test/NamedEnum/Test-NamedEnum.C b/applications/test/NamedEnum/Test-NamedEnum.C index 63386ed79e..08d1f74972 100644 --- a/applications/test/NamedEnum/Test-NamedEnum.C +++ b/applications/test/NamedEnum/Test-NamedEnum.C @@ -77,24 +77,12 @@ int main(int argc, char *argv[]) << "] = '" << namedEnumTest::namedEnum[opt] << "'" << nl; } -#if __cplusplus > 201100L - // C++11 Info<< "loop over enums (C++11 for range):" << nl; - for (auto const& opt : options) + for (const auto& opt : options) { Info<< "option[" << opt << "] = '" << namedEnumTest::namedEnum[opt] << "'" << nl; } -#else - Info<< "loop over enums (via iterator):" << nl; - forAllConstIter(List, options, iter) - { - const namedEnumTest::option& opt = *iter; - - Info<< "option[" << opt - << "] = '" << namedEnumTest::namedEnum[opt] << "'" << nl; - } -#endif Info<< nl << namedEnumTest::namedEnum["a"] << nl diff --git a/applications/test/SLList/Test-SLList.C b/applications/test/SLList/Test-SLList.C index 30baaa18e3..d46fbf6e8e 100644 --- a/applications/test/SLList/Test-SLList.C +++ b/applications/test/SLList/Test-SLList.C @@ -52,29 +52,29 @@ int main(int argc, char *argv[]) Info<< nl << "And again using STL iterator: " << nl << endl; - forAllIter(SLList, myList, iter) + for (auto const& val : myList) { - Info<< "element:" << *iter << endl; + Info<< "element:" << val << endl; } Info<< nl << "And again using STL const_iterator: " << nl << endl; const SLList& const_myList = myList; - forAllConstIter(SLList, const_myList, iter) + forAllConstIters(const_myList, iter) { Info<< "element:" << *iter << endl; } - forAllIter(SLList, myList, iter) + forAllIters(myList, iter) { Info<< "Removing element:" << *iter << endl; myList.remove(iter); } - forAllConstIter(SLList, const_myList, iter) + for (auto const& val : const_myList) { - Info<< "element:" << *iter << endl; + Info<< "element:" << val << endl; } diff --git a/applications/test/labelRanges/Test-labelRanges.C b/applications/test/labelRanges/Test-labelRanges.C index dec03a06f0..a85d2a14dc 100644 --- a/applications/test/labelRanges/Test-labelRanges.C +++ b/applications/test/labelRanges/Test-labelRanges.C @@ -28,10 +28,6 @@ Description \*---------------------------------------------------------------------------*/ #include "argList.H" -#include "IOobject.H" -#include "IOstreams.H" -#include "IFstream.H" -#include "IStringStream.H" #include "labelRanges.H" using namespace Foam; @@ -42,6 +38,7 @@ using namespace Foam; int main(int argc, char *argv[]) { argList::noParallel(); + argList::noFunctionObjects(); argList::validArgs.insert("start size .. startN sizeN"); argList::addOption("verbose"); argList::addNote @@ -76,12 +73,9 @@ int main(int argc, char *argv[]) } { - label start = 0; - label size = 0; - - IStringStream(args[argI])() >> start; + label start = args.argRead