summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/libcamera/internal/utils.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/libcamera/internal/utils.h b/include/libcamera/internal/utils.h
index f08134af..d0146b71 100644
--- a/include/libcamera/internal/utils.h
+++ b/include/libcamera/internal/utils.h
@@ -203,6 +203,33 @@ constexpr unsigned int alignUp(unsigned int value, unsigned int alignment)
return (value + alignment - 1) / alignment * alignment;
}
+namespace details {
+
+template<typename T>
+struct reverse_adapter {
+ T &iterable;
+};
+
+template<typename T>
+auto begin(reverse_adapter<T> r)
+{
+ return std::rbegin(r.iterable);
+}
+
+template<typename T>
+auto end(reverse_adapter<T> r)
+{
+ return std::rend(r.iterable);
+}
+
+} /* namespace details */
+
+template<typename T>
+details::reverse_adapter<T> reverse(T &&iterable)
+{
+ return { iterable };
+}
+
} /* namespace utils */
} /* namespace libcamera */