From a0bba7495016b14c4d7b75d31dfac5bb078f727c Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 14 May 2025 11:47:14 +0200 Subject: [PATCH] STYLE: remove old (__cplusplus >= 201703L) checks - now using c++17 throughout --- applications/test/Hashing2/Make/files | 2 +- .../{Test-Hashing2.C => Test-Hashing2.cxx} | 4 +- applications/test/ICharStream1/Make/files | 2 +- ...t-ICharStream1.C => Test-ICharStream1.cxx} | 15 +-- applications/test/ITstream/Test-ITstream.cxx | 7 +- .../{Test-ListRead1.C => Test-ListRead1.cxx} | 4 +- applications/test/OCharStream1/Make/files | 2 +- ...t-OCharStream1.C => Test-OCharStream1.cxx} | 15 +-- applications/test/SpanStream1/Make/files | 2 +- ...est-SpanStream1.C => Test-SpanStream1.cxx} | 15 +-- applications/test/dictionaryTokens/Make/files | 4 +- ...naryTokens.C => Test-dictionaryTokens.cxx} | 0 ...ictionaryTokens.C => dictionaryTokens.cxx} | 0 applications/test/string_view1/Make/files | 2 +- ...t-string_view1.C => Test-string_view1.cxx} | 7 -- applications/test/token/Test-token.cxx | 106 +++++++++--------- applications/test/tokenize/Make/files | 2 +- .../{Test-tokenize.C => Test-tokenize.cxx} | 0 src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H | 2 - src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C | 7 -- src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H | 6 - .../db/IOstreams/memory/ISpanStream.H | 8 -- .../db/IOstreams/memory/memoryStreamBuffer.H | 16 +-- .../formattingEntry/formattingEntry.C | 6 +- .../primitives/strings/lists/SubStrings.H | 4 - 25 files changed, 82 insertions(+), 156 deletions(-) rename applications/test/Hashing2/{Test-Hashing2.C => Test-Hashing2.cxx} (99%) rename applications/test/ICharStream1/{Test-ICharStream1.C => Test-ICharStream1.cxx} (96%) rename applications/test/ListRead1/{Test-ListRead1.C => Test-ListRead1.cxx} (99%) rename applications/test/OCharStream1/{Test-OCharStream1.C => Test-OCharStream1.cxx} (96%) rename applications/test/SpanStream1/{Test-SpanStream1.C => Test-SpanStream1.cxx} (96%) rename applications/test/dictionaryTokens/{Test-dictionaryTokens.C => Test-dictionaryTokens.cxx} (100%) rename applications/test/dictionaryTokens/{dictionaryTokens.C => dictionaryTokens.cxx} (100%) rename applications/test/string_view1/{Test-string_view1.C => Test-string_view1.cxx} (92%) rename applications/test/tokenize/{Test-tokenize.C => Test-tokenize.cxx} (100%) diff --git a/applications/test/Hashing2/Make/files b/applications/test/Hashing2/Make/files index 86776cfe25..911922f768 100644 --- a/applications/test/Hashing2/Make/files +++ b/applications/test/Hashing2/Make/files @@ -1,3 +1,3 @@ -Test-Hashing2.C +Test-Hashing2.cxx EXE = $(FOAM_USER_APPBIN)/Test-Hashing2 diff --git a/applications/test/Hashing2/Test-Hashing2.C b/applications/test/Hashing2/Test-Hashing2.cxx similarity index 99% rename from applications/test/Hashing2/Test-Hashing2.C rename to applications/test/Hashing2/Test-Hashing2.cxx index 244afbbcc5..4fc27a566a 100644 --- a/applications/test/Hashing2/Test-Hashing2.C +++ b/applications/test/Hashing2/Test-Hashing2.cxx @@ -274,9 +274,7 @@ int main(int argc, char *argv[]) Info<< nl << "No " << is.name() << " file found ..." << nl; } - token tok; - - while (is.good() && is.read(tok) && tok.good()) + for (token tok; tok.read(is); /*nil*/) { const word listType(tok.wordToken()); diff --git a/applications/test/ICharStream1/Make/files b/applications/test/ICharStream1/Make/files index e7f106f94a..9cab0c781d 100644 --- a/applications/test/ICharStream1/Make/files +++ b/applications/test/ICharStream1/Make/files @@ -1,3 +1,3 @@ -Test-ICharStream1.C +Test-ICharStream1.cxx EXE = $(FOAM_USER_APPBIN)/Test-ICharStream1 diff --git a/applications/test/ICharStream1/Test-ICharStream1.C b/applications/test/ICharStream1/Test-ICharStream1.cxx similarity index 96% rename from applications/test/ICharStream1/Test-ICharStream1.C rename to applications/test/ICharStream1/Test-ICharStream1.cxx index cf36c3cddd..97853911c7 100644 --- a/applications/test/ICharStream1/Test-ICharStream1.C +++ b/applications/test/ICharStream1/Test-ICharStream1.cxx @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2023 OpenCFD Ltd. + Copyright (C) 2017-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -83,12 +83,10 @@ Ostream& printView(Ostream& os, const char* first, const char* last) } -#if __cplusplus >= 201703L Ostream& printView(Ostream& os, std::string_view s) { return printView(os, s.begin(), s.end()); } -#endif Ostream& printView(Ostream& os, stdFoam::span s) @@ -138,17 +136,10 @@ void printInfo(const List& buf) void printTokens(Istream& is) { label count = 0; - token t; - while (is.good()) + for (token tok; tok.read(is); ++count) { - is >> t; - if (t.good()) - { - ++count; - Info<<"token: " << t << endl; - } + Info<< "token: " << tok << nl; } - Info<< count << " tokens" << endl; } diff --git a/applications/test/ITstream/Test-ITstream.cxx b/applications/test/ITstream/Test-ITstream.cxx index 6aa034b04a..17592aed89 100644 --- a/applications/test/ITstream/Test-ITstream.cxx +++ b/applications/test/ITstream/Test-ITstream.cxx @@ -73,14 +73,13 @@ Ostream& toString(Ostream& os, const List& list) void printTokens(Istream& is) { - label count = 0; - Info<< "stream tokens:" << endl; + + label count = 0; for (token tok; tok.read(is); ++count) { - Info<< " : " << tok << endl; + Info<< " : " << tok << nl; } - Info<< count << " tokens" << endl; } diff --git a/applications/test/ListRead1/Test-ListRead1.C b/applications/test/ListRead1/Test-ListRead1.cxx similarity index 99% rename from applications/test/ListRead1/Test-ListRead1.C rename to applications/test/ListRead1/Test-ListRead1.cxx index aac211e2da..db9926a58e 100644 --- a/applications/test/ListRead1/Test-ListRead1.C +++ b/applications/test/ListRead1/Test-ListRead1.cxx @@ -85,7 +85,7 @@ bool readBracketList(List& list, Istream& is) // constexpr label chunkSize = 128; typedef std::unique_ptr> chunkType; - is >> tok; + tok.read(is); is.fatalCheck(FUNCTION_NAME); if (tok.isPunctuation(token::END_LIST)) @@ -149,7 +149,7 @@ bool readBracketList(List& list, Istream& is) "reading entry" ); - is >> tok; + tok.read(is); is.fatalCheck(FUNCTION_NAME); } diff --git a/applications/test/OCharStream1/Make/files b/applications/test/OCharStream1/Make/files index 5613de82c1..9bb340983c 100644 --- a/applications/test/OCharStream1/Make/files +++ b/applications/test/OCharStream1/Make/files @@ -1,3 +1,3 @@ -Test-OCharStream1.C +Test-OCharStream1.cxx EXE = $(FOAM_USER_APPBIN)/Test-OCharStream1 diff --git a/applications/test/OCharStream1/Test-OCharStream1.C b/applications/test/OCharStream1/Test-OCharStream1.cxx similarity index 96% rename from applications/test/OCharStream1/Test-OCharStream1.C rename to applications/test/OCharStream1/Test-OCharStream1.cxx index f4039f231b..7499b9c04a 100644 --- a/applications/test/OCharStream1/Test-OCharStream1.C +++ b/applications/test/OCharStream1/Test-OCharStream1.cxx @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2023 OpenCFD Ltd. + Copyright (C) 2017-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -83,12 +83,10 @@ Ostream& printView(Ostream& os, const char* first, const char* last) } -#if __cplusplus >= 201703L Ostream& printView(Ostream& os, std::string_view s) { return printView(os, s.begin(), s.end()); } -#endif Ostream& printView(Ostream& os, stdFoam::span s) @@ -129,17 +127,10 @@ void printInfo(const BufType& buf) void printTokens(Istream& is) { label count = 0; - token t; - while (is.good()) + for (token tok; tok.read(is); ++count) { - is >> t; - if (t.good()) - { - ++count; - Info<<"token: " << t << endl; - } + Info<< "token: " << tok << nl; } - Info<< count << " tokens" << endl; } diff --git a/applications/test/SpanStream1/Make/files b/applications/test/SpanStream1/Make/files index 4af7ed78cd..8ec12e8b23 100644 --- a/applications/test/SpanStream1/Make/files +++ b/applications/test/SpanStream1/Make/files @@ -1,3 +1,3 @@ -Test-SpanStream1.C +Test-SpanStream1.cxx EXE = $(FOAM_USER_APPBIN)/Test-SpanStream1 diff --git a/applications/test/SpanStream1/Test-SpanStream1.C b/applications/test/SpanStream1/Test-SpanStream1.cxx similarity index 96% rename from applications/test/SpanStream1/Test-SpanStream1.C rename to applications/test/SpanStream1/Test-SpanStream1.cxx index 92fb58daa0..6e6e988b14 100644 --- a/applications/test/SpanStream1/Test-SpanStream1.C +++ b/applications/test/SpanStream1/Test-SpanStream1.cxx @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2023 OpenCFD Ltd. + Copyright (C) 2017-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -85,12 +85,10 @@ Ostream& printView(Ostream& os, const char* first, const char* last) } -#if __cplusplus >= 201703L Ostream& printView(Ostream& os, std::string_view s) { return printView(os, s.begin(), s.end()); } -#endif Ostream& printView(Ostream& os, stdFoam::span s) @@ -145,17 +143,10 @@ void printInfo(const UList& buf) void printTokens(Istream& is) { label count = 0; - token t; - while (is.good()) + for (token tok; tok.read(is); ++count) { - is >> t; - if (t.good()) - { - ++count; - Info<<"token: " << t << endl; - } + Info<< "token: " << tok << nl; } - Info<< count << " tokens" << endl; } diff --git a/applications/test/dictionaryTokens/Make/files b/applications/test/dictionaryTokens/Make/files index 413023a014..501c165765 100644 --- a/applications/test/dictionaryTokens/Make/files +++ b/applications/test/dictionaryTokens/Make/files @@ -1,4 +1,4 @@ -Test-dictionaryTokens.C -dictionaryTokens.C +Test-dictionaryTokens.cxx +dictionaryTokens.cxx EXE = $(FOAM_USER_APPBIN)/Test-dictionaryTokens diff --git a/applications/test/dictionaryTokens/Test-dictionaryTokens.C b/applications/test/dictionaryTokens/Test-dictionaryTokens.cxx similarity index 100% rename from applications/test/dictionaryTokens/Test-dictionaryTokens.C rename to applications/test/dictionaryTokens/Test-dictionaryTokens.cxx diff --git a/applications/test/dictionaryTokens/dictionaryTokens.C b/applications/test/dictionaryTokens/dictionaryTokens.cxx similarity index 100% rename from applications/test/dictionaryTokens/dictionaryTokens.C rename to applications/test/dictionaryTokens/dictionaryTokens.cxx diff --git a/applications/test/string_view1/Make/files b/applications/test/string_view1/Make/files index 4d92aada22..c11f6fa346 100644 --- a/applications/test/string_view1/Make/files +++ b/applications/test/string_view1/Make/files @@ -1,3 +1,3 @@ -Test-string_view1.C +Test-string_view1.cxx EXE = $(FOAM_USER_APPBIN)/Test-string_view1 diff --git a/applications/test/string_view1/Test-string_view1.C b/applications/test/string_view1/Test-string_view1.cxx similarity index 92% rename from applications/test/string_view1/Test-string_view1.C rename to applications/test/string_view1/Test-string_view1.cxx index 155e364165..bbb24dc8fe 100644 --- a/applications/test/string_view1/Test-string_view1.C +++ b/applications/test/string_view1/Test-string_view1.cxx @@ -40,11 +40,6 @@ using namespace Foam; int main(int argc, char *argv[]) { Info<< "Compiled with C++ " << __cplusplus; - #if __cplusplus >= 201703L - Info<< " - has std::string_view" << nl << nl; - #else - Info<< " - NO std::string_view" << nl << nl; - #endif // basics { @@ -63,9 +58,7 @@ int main(int argc, char *argv[]) << "input: <" << cstr << '>' << " type: " << typeid(cstr).name() << " len:" << len << nl; - #if __cplusplus >= 201703L Info<< " view: " << std::string_view(cstr) << nl; - #endif Info<< " span: " << stdFoam::span(cstr, len) << nl; diff --git a/applications/test/token/Test-token.cxx b/applications/test/token/Test-token.cxx index 52b2eb7571..7fda54b642 100644 --- a/applications/test/token/Test-token.cxx +++ b/applications/test/token/Test-token.cxx @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2024 OpenCFD Ltd. + Copyright (C) 2017-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -134,50 +134,51 @@ int main(int argc, char *argv[]) Info<< "resized: " << ctok1.info() << nl << ctok1 << endl; + // Using isA<> on compoundToken() + if + ( + const auto* listptr + = ctok1.compoundToken().isA() + ) { - // Using isA<> on compoundToken() - const auto* listptr = ctok1.compoundToken().isA(); - if (listptr) - { - // sneaky, SubField bypasses const! - scalarField::subField fld(*listptr); - fld *= 5; + // sneaky, SubField bypasses const! + scalarField::subField fld(*listptr); + fld *= 5; - Info<< "multiplied List: " - << ctok1.info() << nl << ctok1 << endl; - } + Info<< "multiplied List: " + << ctok1.info() << nl << ctok1 << endl; } + // Using isCompound<...> - combined check + if + ( + const auto* listptr + = ctok1.isCompound() + ) { - // Using isCompound<...> - combined check + scalarField::subField fld(*listptr); + fld /= 2; - const auto* listptr = ctok1.isCompound(); - if (listptr) - { - scalarField::subField fld(*listptr); - fld /= 2; - - Info<< "divided List: " - << ctok1.info() << nl << ctok1 << endl; - } + Info<< "divided List: " + << ctok1.info() << nl << ctok1 << endl; } + // Using isCompound<...> - combined check + if + ( + const auto* listptr + = ctok1.isCompound() + ) { - // Using isCompound<...> - combined check + labelField::subField fld(*listptr); + fld /= 2; - const auto* listptr = ctok1.isCompound(); - if (listptr) - { - labelField::subField fld(*listptr); - fld /= 2; - - Info<< "divided List