From 40567b844a2037ce931ea8a5b552177af2123b4e Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 4 May 2021 14:25:28 +0200 Subject: [PATCH] DEFEATURE: remove construct List from two iterators (#2083) - this constructor was added for similarity with std::vector, but continues to cause various annoyances. The main problem is that the templated parameter tends to grab anything that is not a perfect match for other constructors. Typically seen with two integers (in 64-bit mode), but various other cases as well. If required, the ListOps::create() function provides a lengthier alternative but one that can also incorporate transformations. Eg, pointField pts = ....; List mags ( List::create ( pts.begin(), pts.end(), [](const vector& v){ return magSqr(v); } ); --- applications/test/List/Test-List.C | 16 ++++++++++++++++ .../test/zoneDistribute/Test-zoneDistribute.C | 2 -- .../containers/Lists/DynamicList/DynamicList.H | 5 ----- .../containers/Lists/DynamicList/DynamicListI.H | 13 ------------- src/OpenFOAM/containers/Lists/List/List.C | 8 -------- src/OpenFOAM/containers/Lists/List/List.H | 5 ----- 6 files changed, 16 insertions(+), 33 deletions(-) diff --git a/applications/test/List/Test-List.C b/applications/test/List/Test-List.C index 16b3210958..4f52872b94 100644 --- a/applications/test/List/Test-List.C +++ b/applications/test/List/Test-List.C @@ -55,6 +55,9 @@ See also #include #include +// see issue #2083 +#undef Foam_constructList_from_iterators + namespace Foam { @@ -254,8 +257,12 @@ int main(int argc, char *argv[]) Info<< "list4: " << list4 << nl << "list5: " << list5 << endl; + #ifdef Foam_constructList_from_iterators List list6(list4.begin(), list4.end()); Info<< "list6: " << list6 << endl; + #else + Info<< "NOTE: no construction from two iterators" << endl; + #endif // Subset const labelList map{0, 2}; @@ -273,9 +280,13 @@ int main(int argc, char *argv[]) // scalarList slist = identity(15); // // More writing, but does work: + #ifdef Foam_constructList_from_iterators scalarList slist(labelRange().begin(), labelRange(15).end()); Info<<"scalar identity:" << flatOutput(slist) << endl; + #else + Info<<"No iterator means of creating a scalar identity list" << endl; + #endif printListOutputType