aboutsummaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2022-06-28 21:14:17 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2022-06-28 21:14:17 +0100
commit508f8da2f6597aa76d779bd0f66f0bc4205c9c5e (patch)
tree448a49c836475db2cb2d32bca69d9dbfb5b48a28 /src/client
parent2e4857278d8f1bb3b87367ab0ab306044ffe9c55 (diff)
downloadrspamd-508f8da2f6597aa76d779bd0f66f0bc4205c9c5e.tar.gz
rspamd-508f8da2f6597aa76d779bd0f66f0bc4205c9c5e.zip
Revert "[Minor] C++20 is here"
This change is not so useful to break compatibility with Clang 7. Maybe later... This reverts commit 48ce799a7a5cf1bde8440e3e75a677ee3e467c9d.
Diffstat (limited to 'src/client')
-rw-r--r--src/client/rspamc.cxx8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/client/rspamc.cxx b/src/client/rspamc.cxx
index 44dca0771..3615d3be5 100644
--- a/src/client/rspamc.cxx
+++ b/src/client/rspamc.cxx
@@ -427,6 +427,12 @@ static const auto sort_map = frozen::make_unordered_map<frozen::string, sort_lam
}},
});
+/* TODO: remove once migrate to C++20 standard */
+static constexpr auto
+sv_ends_with(std::string_view inp, std::string_view suffix) -> bool {
+ return inp.size() >= suffix.size() && inp.compare(inp.size() - suffix.size(), std::string_view::npos, suffix) == 0;
+}
+
template<typename T>
auto sort_ucl_container_with_default(T &cont, const char *default_sort,
typename std::enable_if<std::is_same_v<typename T::value_type, const ucl_object_t *>>::type* = 0) -> void
@@ -436,7 +442,7 @@ auto sort_ucl_container_with_default(T &cont, const char *default_sort,
auto sort_view = std::string_view{real_sort};
auto inverse = false;
- if (sort_view.ends_with(":asc")) {
+ if (sv_ends_with(sort_view, ":asc")) {
inverse = true;
sort_view = std::string_view{sort, strlen(sort) - sizeof(":asc") + 1};
}