Skip to content

Commit

Permalink
C++20 fixes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ccotter committed Oct 18, 2023
1 parent 63fd3c9 commit fe0fa78
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/groups/mqb/mqbs/mqbs_storagecollectionutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,31 @@ void StorageCollectionUtil::loadStorages(StorageList* storages,
}
}

namespace {

template <class Predicate>
struct Not1 {
Not1(const Predicate& predicate)
: d_predicate(predicate)
{
}

template <class Value>
bool operator()(const Value& value) const
{
return !d_predicate(value);
}
Predicate d_predicate;
};

template <class Predicate>
Not1<Predicate> not_pred(const Predicate& predicate)
{
return Not1<Predicate>(predicate);
}

} // close anonymous namespace

void StorageCollectionUtil::filterStorages(StorageList* storages,
const StorageFilter& filter)
{
Expand All @@ -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());
}

Expand Down

0 comments on commit fe0fa78

Please sign in to comment.