COMP: avoid constructor ambiguity for ISpanStream

- compiler cannot decide between std::string and std::string_view
  when creating from 'const char*' without also supplying the size,
  so also supply a 'const char*' constructor.

ENH: additional string_view handling for ITstream and SubStrings
This commit is contained in:
Mark Olesen
2025-03-11 14:01:59 +01:00
parent 36ae93d017
commit 38e08fc092
7 changed files with 103 additions and 82 deletions

View File

@ -1,3 +1,3 @@
Test-stringSplit.C
Test-stringSplit.cxx
EXE = $(FOAM_USER_APPBIN)/Test-stringSplit

View File

@ -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.
@ -50,11 +50,12 @@ void printSubStrings
<< split.size() << " elements {" << split.length() << " chars}"
<< nl;
unsigned i = 0;
for (const auto s : split)
for (unsigned i = 0; i < split.size(); ++i)
{
Info<< "[" << i++ << "] {" << s.length() << " chars} = "
<< s.str() << nl;
const auto& s = split[i];
Info<< "[" << i << "] {" << s.length() << " chars} = "
<< split.view(i) << " == " << s.str()
<< nl;
}
}