mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: remove old (__cplusplus >= 201703L) checks
- now using c++17 throughout
This commit is contained in:
@ -1,3 +1,3 @@
|
||||
Test-Hashing2.C
|
||||
Test-Hashing2.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-Hashing2
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-ICharStream1.C
|
||||
Test-ICharStream1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-ICharStream1
|
||||
|
||||
@ -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<char> s)
|
||||
@ -138,17 +136,10 @@ void printInfo(const List<char>& 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;
|
||||
}
|
||||
|
||||
@ -73,14 +73,13 @@ Ostream& toString(Ostream& os, const List<char>& 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;
|
||||
}
|
||||
|
||||
|
||||
@ -85,7 +85,7 @@ bool readBracketList(List<T>& list, Istream& is)
|
||||
// constexpr label chunkSize = 128;
|
||||
typedef std::unique_ptr<List<T>> chunkType;
|
||||
|
||||
is >> tok;
|
||||
tok.read(is);
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
if (tok.isPunctuation(token::END_LIST))
|
||||
@ -149,7 +149,7 @@ bool readBracketList(List<T>& list, Istream& is)
|
||||
"reading entry"
|
||||
);
|
||||
|
||||
is >> tok;
|
||||
tok.read(is);
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-OCharStream1.C
|
||||
Test-OCharStream1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-OCharStream1
|
||||
|
||||
@ -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<char> 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;
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-SpanStream1.C
|
||||
Test-SpanStream1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-SpanStream1
|
||||
|
||||
@ -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<char> s)
|
||||
@ -145,17 +143,10 @@ void printInfo(const UList<char>& 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;
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
Test-dictionaryTokens.C
|
||||
dictionaryTokens.C
|
||||
Test-dictionaryTokens.cxx
|
||||
dictionaryTokens.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-dictionaryTokens
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-string_view1.C
|
||||
Test-string_view1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-string_view1
|
||||
|
||||
@ -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<const char>(cstr, len) << nl;
|
||||
@ -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<scalarList>()
|
||||
)
|
||||
{
|
||||
// Using isA<> on compoundToken()
|
||||
const auto* listptr = ctok1.compoundToken().isA<scalarList>();
|
||||
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<scalar>: "
|
||||
<< ctok1.info() << nl << ctok1 << endl;
|
||||
}
|
||||
Info<< "multiplied List<scalar>: "
|
||||
<< ctok1.info() << nl << ctok1 << endl;
|
||||
}
|
||||
|
||||
// Using isCompound<...> - combined check
|
||||
if
|
||||
(
|
||||
const auto* listptr
|
||||
= ctok1.isCompound<scalarList>()
|
||||
)
|
||||
{
|
||||
// Using isCompound<...> - combined check
|
||||
scalarField::subField fld(*listptr);
|
||||
fld /= 2;
|
||||
|
||||
const auto* listptr = ctok1.isCompound<scalarList>();
|
||||
if (listptr)
|
||||
{
|
||||
scalarField::subField fld(*listptr);
|
||||
fld /= 2;
|
||||
|
||||
Info<< "divided List<scalar>: "
|
||||
<< ctok1.info() << nl << ctok1 << endl;
|
||||
}
|
||||
Info<< "divided List<scalar>: "
|
||||
<< ctok1.info() << nl << ctok1 << endl;
|
||||
}
|
||||
|
||||
// Using isCompound<...> - combined check
|
||||
if
|
||||
(
|
||||
const auto* listptr
|
||||
= ctok1.isCompound<labelList>()
|
||||
)
|
||||
{
|
||||
// Using isCompound<...> - combined check
|
||||
labelField::subField fld(*listptr);
|
||||
fld /= 2;
|
||||
|
||||
const auto* listptr = ctok1.isCompound<labelList>();
|
||||
if (listptr)
|
||||
{
|
||||
labelField::subField fld(*listptr);
|
||||
fld /= 2;
|
||||
|
||||
Info<< "divided List<label>: "
|
||||
<< ctok1.info() << nl << ctok1 << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "compound is not List<label>" << nl;
|
||||
}
|
||||
Info<< "divided List<label>: "
|
||||
<< ctok1.info() << nl << ctok1 << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "compound is not List<label>" << nl;
|
||||
}
|
||||
|
||||
Info<< "Before fill_zero: " << ctok1 << endl;
|
||||
@ -248,13 +249,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
token tok;
|
||||
|
||||
if (auto v = obuf.view(); !v.empty())
|
||||
{
|
||||
auto v = obuf.view();
|
||||
if (!v.empty())
|
||||
{
|
||||
tok = string(v.data(), v.size());
|
||||
tok.setType(token::tokenType::CHAR_DATA);
|
||||
}
|
||||
tok = string(v.data(), v.size());
|
||||
tok.setType(token::tokenType::CHAR_DATA);
|
||||
}
|
||||
else
|
||||
{
|
||||
tok = token();
|
||||
}
|
||||
|
||||
Info<< "tok: " << tok.name() << nl << nl;
|
||||
@ -274,13 +276,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
obuf.endBlock();
|
||||
|
||||
if (auto v = obuf.view(); !v.empty())
|
||||
{
|
||||
auto v = obuf.view();
|
||||
if (!v.empty())
|
||||
{
|
||||
tok = string(v.data(), v.size());
|
||||
tok.setType(token::tokenType::CHAR_DATA);
|
||||
}
|
||||
tok = string(v.data(), v.size());
|
||||
tok.setType(token::tokenType::CHAR_DATA);
|
||||
}
|
||||
else
|
||||
{
|
||||
tok = token();
|
||||
}
|
||||
|
||||
// Output like xml:
|
||||
@ -349,10 +352,11 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
typedef List<scalar> ListType;
|
||||
|
||||
auto* inputDataPtr =
|
||||
const_cast<ListType*>(entry0.stream().findCompound<ListType>());
|
||||
|
||||
if (inputDataPtr)
|
||||
if
|
||||
(
|
||||
auto* inputDataPtr
|
||||
= const_cast<ListType*>(entry0.stream().findCompound<ListType>())
|
||||
)
|
||||
{
|
||||
Info<< "found input data" << nl;
|
||||
Info<< entry0 << nl;
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-tokenize.C
|
||||
Test-tokenize.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-tokenize
|
||||
|
||||
Reference in New Issue
Block a user