summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/util
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2022-07-31 02:31:40 +1000
committer Vas Crabb <vas@vastheman.com>2022-07-31 02:31:40 +1000
commite98145d9d8e6cec0c98883d5b5c887fd21d01d27 (patch)
treefe45babea2ad0118014e6b0a326d163d4f528016 /src/lib/util
parent1bf2cc0cf347aa65d1dc0021dd8c7317b14a49cf (diff)
Various minor cleanups.
There's something wrong when derived classes need to be friends...
Diffstat (limited to 'src/lib/util')
-rw-r--r--src/lib/util/corestr.cpp6
-rw-r--r--src/lib/util/corestr.h20
2 files changed, 10 insertions, 16 deletions
diff --git a/src/lib/util/corestr.cpp b/src/lib/util/corestr.cpp
index 90009411c9c..85e7e517665 100644
--- a/src/lib/util/corestr.cpp
+++ b/src/lib/util/corestr.cpp
@@ -148,13 +148,13 @@ void strreplacechr(std::string& str, char ch, char newch)
std::string_view strtrimspace(std::string_view str)
{
- std::string_view str2 = strtrimleft(str, [](char c) { return !isspace(uint8_t(c)); });
- return strtrimright(str2, [](char c) { return !isspace(uint8_t(c)); });
+ std::string_view str2 = strtrimleft(str, [] (char c) { return !isspace(uint8_t(c)); });
+ return strtrimright(str2, [] (char c) { return !isspace(uint8_t(c)); });
}
std::string_view strtrimrightspace(std::string_view str)
{
- return strtrimright(str, [](char c) { return !isspace(uint8_t(c)); });
+ return strtrimright(str, [] (char c) { return !isspace(uint8_t(c)); });
}
std::string strmakeupper(std::string_view str)
diff --git a/src/lib/util/corestr.h b/src/lib/util/corestr.h
index 8caf014509b..d5b79ddb5fa 100644
--- a/src/lib/util/corestr.h
+++ b/src/lib/util/corestr.h
@@ -53,23 +53,17 @@ int core_strwildcmp(const char *sp1, const char *sp2);
bool core_iswildstr(const char *sp);
/* trim functions */
-template<typename TPred>
-std::string_view strtrimleft(std::string_view str, TPred pred)
+template <typename TPred>
+std::string_view strtrimleft(std::string_view str, TPred &&pred)
{
- std::string_view::iterator start = std::find_if(
- str.begin(),
- str.end(),
- pred);
- return str.substr(start - str.begin(), str.end() - start);
+ auto const start = std::find_if(str.begin(), str.end(), pred);
+ return str.substr(start - str.begin());
}
-template<typename TPred>
-std::string_view strtrimright(std::string_view str, TPred pred)
+template <typename TPred>
+std::string_view strtrimright(std::string_view str, TPred &&pred)
{
- std::string_view::reverse_iterator end = std::find_if(
- str.rbegin(),
- str.rend(),
- pred);
+ auto const end = std::find_if(str.rbegin(), str.rend(), pred);
return str.substr(0, str.size() - (end - str.rbegin()));
}