From 708d49b08b1a0c9d9976c2438f7a25c4ed571f7e Mon Sep 17 00:00:00 2001 From: Chris Cotter Date: Fri, 20 Oct 2023 10:12:54 -0400 Subject: [PATCH] C++20 fixes (#130) std::not1 is removed from C++20. Since this code is expected to be built on C++03 as well as C++11 and newer, this patch embeds an adhoc version of 'not1' instead of, e.g., using a lambda expression. Signed-off-by: Chris Cotter --- .../mqb/mqbs/mqbs_storagecollectionutil.cpp | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/groups/mqb/mqbs/mqbs_storagecollectionutil.cpp b/src/groups/mqb/mqbs/mqbs_storagecollectionutil.cpp index d5222e3c2..5e0b5c1bd 100644 --- a/src/groups/mqb/mqbs/mqbs_storagecollectionutil.cpp +++ b/src/groups/mqb/mqbs/mqbs_storagecollectionutil.cpp @@ -156,6 +156,31 @@ void StorageCollectionUtil::loadStorages(StorageList* storages, } } +namespace { + +template +struct Not1 { + Not1(const Predicate& predicate) + : d_predicate(predicate) + { + } + + template + bool operator()(const Value& value) const + { + return !d_predicate(value); + } + Predicate d_predicate; +}; + +template +Not1 not_pred(const Predicate& predicate) +{ + return Not1(predicate); +} + +} // close anonymous namespace + void StorageCollectionUtil::filterStorages(StorageList* storages, const StorageFilter& filter) { @@ -164,7 +189,7 @@ void StorageCollectionUtil::filterStorages(StorageList* storages, StorageListIter iter = bsl::remove_if(storages->begin(), storages->end(), - bsl::not1(filter)); + not_pred(filter)); storages->erase(iter, storages->end()); }