ENH: add move/swap semantics to string types and regExp

- move append() single element to List and DynamicList

ENH: add stringOps::count to avoid unnecessary string conversions
This commit is contained in:
Mark Olesen
2017-11-05 13:26:10 +01:00
parent cae8a894cd
commit e1b71c028c
24 changed files with 525 additions and 122 deletions

View File

@ -132,6 +132,47 @@ static inline int findParameterAlternative
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
std::string::size_type Foam::stringOps::count
(
const std::string& str,
const char c
)
{
std::string::size_type n = 0;
for (auto iter = str.cbegin(); iter != str.cend(); ++iter)
{
if (*iter == c)
{
++n;
}
}
return n;
}
std::string::size_type Foam::stringOps::count(const char* str, const char c)
{
if (!str)
{
return 0;
}
std::string::size_type n = 0;
for (const char *iter = str; *iter; ++iter)
{
if (*iter == c)
{
++n;
}
}
return n;
}
Foam::string Foam::stringOps::expand
(
const string& original,