util/Concepts: remove obsolete fallbacks
This commit is contained in:
parent
aeadae5399
commit
acc92b156b
|
@ -5,33 +5,5 @@
|
||||||
|
|
||||||
#include <concepts>
|
#include <concepts>
|
||||||
|
|
||||||
/**
|
|
||||||
* Compatibility wrapper for std::invocable which is unavailable in
|
|
||||||
* the Android NDK r25b and Apple Xcode.
|
|
||||||
*/
|
|
||||||
#if !defined(ANDROID) && !defined(__APPLE__)
|
|
||||||
template<typename F, typename... Args>
|
|
||||||
concept Invocable = std::invocable<F, Args...>;
|
|
||||||
#else
|
|
||||||
template<typename F, typename... Args>
|
|
||||||
concept Invocable = requires(F f, Args... args) {
|
|
||||||
{ f(args...) };
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compatibility wrapper for std::predicate which is unavailable in
|
|
||||||
* the Android NDK r25b and Apple Xcode.
|
|
||||||
*/
|
|
||||||
#if !defined(ANDROID) && !defined(__APPLE__)
|
|
||||||
template<typename F, typename... Args>
|
|
||||||
concept Predicate = std::predicate<F, Args...>;
|
|
||||||
#else
|
|
||||||
template<typename F, typename... Args>
|
|
||||||
concept Predicate = requires(F f, Args... args) {
|
|
||||||
{ f(args...) } -> std::same_as<bool>;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename F, typename T>
|
template<typename F, typename T>
|
||||||
concept Disposer = Invocable<F, T *>;
|
concept Disposer = std::invocable<F, T *>;
|
||||||
|
|
|
@ -182,7 +182,7 @@ public:
|
||||||
counter.reset();
|
counter.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove_and_dispose_if(Predicate<const_reference> auto pred,
|
void remove_and_dispose_if(std::predicate<const_reference> auto pred,
|
||||||
Disposer<value_type> auto disposer) noexcept {
|
Disposer<value_type> auto disposer) noexcept {
|
||||||
for (auto &bucket : table)
|
for (auto &bucket : table)
|
||||||
counter -= bucket.remove_and_dispose_if(pred, disposer);
|
counter -= bucket.remove_and_dispose_if(pred, disposer);
|
||||||
|
@ -200,7 +200,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr void remove_and_dispose_if(const auto &key,
|
constexpr void remove_and_dispose_if(const auto &key,
|
||||||
Predicate<const_reference> auto pred,
|
std::predicate<const_reference> auto pred,
|
||||||
Disposer<value_type> auto disposer) noexcept {
|
Disposer<value_type> auto disposer) noexcept {
|
||||||
auto &bucket = GetBucket(key);
|
auto &bucket = GetBucket(key);
|
||||||
counter -= bucket.remove_and_dispose_if([this, &key, &pred](const auto &item){
|
counter -= bucket.remove_and_dispose_if([this, &key, &pred](const auto &item){
|
||||||
|
@ -296,7 +296,7 @@ public:
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] [[gnu::pure]]
|
[[nodiscard]] [[gnu::pure]]
|
||||||
constexpr bucket_iterator find_if(const auto &key,
|
constexpr bucket_iterator find_if(const auto &key,
|
||||||
Predicate<const_reference> auto pred) noexcept {
|
std::predicate<const_reference> auto pred) noexcept {
|
||||||
auto &bucket = GetBucket(key);
|
auto &bucket = GetBucket(key);
|
||||||
for (auto &i : bucket)
|
for (auto &i : bucket)
|
||||||
if (equal(key, i) && pred(i))
|
if (equal(key, i) && pred(i))
|
||||||
|
@ -320,9 +320,9 @@ public:
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] [[gnu::pure]]
|
[[nodiscard]] [[gnu::pure]]
|
||||||
constexpr bucket_iterator expire_find_if(const auto &key,
|
constexpr bucket_iterator expire_find_if(const auto &key,
|
||||||
Predicate<const_reference> auto expired_pred,
|
std::predicate<const_reference> auto expired_pred,
|
||||||
Disposer<value_type> auto disposer,
|
Disposer<value_type> auto disposer,
|
||||||
Predicate<const_reference> auto match_pred) noexcept {
|
std::predicate<const_reference> auto match_pred) noexcept {
|
||||||
auto &bucket = GetBucket(key);
|
auto &bucket = GetBucket(key);
|
||||||
|
|
||||||
for (auto i = bucket.begin(), e = bucket.end(); i != e;) {
|
for (auto i = bucket.begin(), e = bucket.end(); i != e;) {
|
||||||
|
|
|
@ -271,7 +271,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @return the number of removed items
|
* @return the number of removed items
|
||||||
*/
|
*/
|
||||||
std::size_t remove_and_dispose_if(Predicate<const_reference> auto pred,
|
std::size_t remove_and_dispose_if(std::predicate<const_reference> auto pred,
|
||||||
Disposer<value_type> auto dispose) noexcept {
|
Disposer<value_type> auto dispose) noexcept {
|
||||||
std::size_t result = 0;
|
std::size_t result = 0;
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Concepts.hxx"
|
|
||||||
#include "StaticVector.hxx"
|
#include "StaticVector.hxx"
|
||||||
|
|
||||||
#include <algorithm> // for std::find_if()
|
#include <algorithm> // for std::find_if()
|
||||||
|
#include <concepts>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move all items from #src to #dest, keeping both sorted.
|
* Move all items from #src to #dest, keeping both sorted.
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
template<typename List>
|
template<typename List>
|
||||||
constexpr void
|
constexpr void
|
||||||
MergeList(List &dest, List &src,
|
MergeList(List &dest, List &src,
|
||||||
Predicate<typename List::const_reference, typename List::const_reference> auto p) noexcept
|
std::predicate<typename List::const_reference, typename List::const_reference> auto p) noexcept
|
||||||
{
|
{
|
||||||
const auto dest_end = dest.end(), src_end = src.end();
|
const auto dest_end = dest.end(), src_end = src.end();
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ MergeList(List &dest, List &src,
|
||||||
template<typename List>
|
template<typename List>
|
||||||
constexpr void
|
constexpr void
|
||||||
SortList(List &list,
|
SortList(List &list,
|
||||||
Predicate <typename List::const_reference, typename List::const_reference> auto p) noexcept
|
std::predicate <typename List::const_reference, typename List::const_reference> auto p) noexcept
|
||||||
{
|
{
|
||||||
using std::swap;
|
using std::swap;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue