Files
macports-ports/audio/ncmpc/files/0003-Revert-util-Concepts-remove-obsolete-fallbacks.patch

99 lines
3.0 KiB
Diff

From d8c70d50503814f712139c0ea67559b2b55f9692 Mon Sep 17 00:00:00 2001
From: barracuda156 <vital.had@gmail.com>
Date: Sat, 19 Aug 2023 10:58:46 +0800
Subject: [PATCH 3/3] Revert "util/Concepts: remove obsolete fallbacks"
This reverts commit 7c88215acb5c1ddd924c53fb6be152cef22a0535.
---
src/util/Concepts.hxx | 30 +++++++++++++++++++++++++++++-
src/util/IntrusiveList.hxx | 2 +-
src/util/SortList.hxx | 6 +++---
3 files changed, 33 insertions(+), 5 deletions(-)
diff --git src/util/Concepts.hxx src/util/Concepts.hxx
index a741d690..6439dd92 100644
--- src/util/Concepts.hxx
+++ src/util/Concepts.hxx
@@ -5,5 +5,33 @@
#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>
-concept Disposer = std::invocable<F, T *>;
+concept Disposer = Invocable<F, T *>;
diff --git src/util/IntrusiveList.hxx src/util/IntrusiveList.hxx
index aa1c67e5..0467f2c6 100644
--- src/util/IntrusiveList.hxx
+++ src/util/IntrusiveList.hxx
@@ -266,7 +266,7 @@ public:
/**
* @return the number of removed items
*/
- std::size_t remove_and_dispose_if(std::predicate<const_reference> auto pred,
+ std::size_t remove_and_dispose_if(Predicate<const_reference> auto pred,
Disposer<value_type> auto dispose) noexcept {
std::size_t result = 0;
diff --git src/util/SortList.hxx src/util/SortList.hxx
index 54a43745..6856872b 100644
--- src/util/SortList.hxx
+++ src/util/SortList.hxx
@@ -3,10 +3,10 @@
#pragma once
+#include "Concepts.hxx"
#include "StaticVector.hxx"
#include <algorithm> // for std::find_if()
-#include <concepts>
/**
* Move all items from #src to #dest, keeping both sorted.
@@ -17,7 +17,7 @@
template<typename List>
constexpr void
MergeList(List &dest, List &src,
- std::predicate<typename List::const_reference, typename List::const_reference> auto p) noexcept
+ Predicate<typename List::const_reference, typename List::const_reference> auto p) noexcept
{
const auto dest_end = dest.end(), src_end = src.end();
@@ -59,7 +59,7 @@ MergeList(List &dest, List &src,
template<typename List>
constexpr void
SortList(List &list,
- std::predicate <typename List::const_reference, typename List::const_reference> auto p) noexcept
+ Predicate <typename List::const_reference, typename List::const_reference> auto p) noexcept
{
using std::swap;