summaryrefslogtreecommitdiff
path: root/src/libcamera
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-02-25 18:36:15 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-02-27 11:48:44 +0200
commitdae4a4406779ba1bc1687446d20c82a1f96b5258 (patch)
tree896806536a5b67064323e1cf8d4335aa4d4cceff /src/libcamera
parent6a50c960be774b44a32f566f1f485cf800cc0527 (diff)
libcamera: Use utils::to_underlying()
Replace manual implementations of the utils::to_underlying() helper with calls to the function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Diffstat (limited to 'src/libcamera')
-rw-r--r--src/libcamera/pipeline/rpi/common/rpi_stream.h10
-rw-r--r--src/libcamera/stream.cpp2
2 files changed, 4 insertions, 8 deletions
diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.h b/src/libcamera/pipeline/rpi/common/rpi_stream.h
index fc2bdfe2..48ed41ab 100644
--- a/src/libcamera/pipeline/rpi/common/rpi_stream.h
+++ b/src/libcamera/pipeline/rpi/common/rpi_stream.h
@@ -14,6 +14,7 @@
#include <vector>
#include <libcamera/base/flags.h>
+#include <libcamera/base/utils.h>
#include <libcamera/stream.h>
@@ -180,19 +181,14 @@ private:
template<typename E, std::size_t N>
class Device : public std::array<class Stream, N>
{
-private:
- constexpr auto index(E e) const noexcept
- {
- return static_cast<std::underlying_type_t<E>>(e);
- }
public:
Stream &operator[](E e)
{
- return std::array<class Stream, N>::operator[](index(e));
+ return std::array<class Stream, N>::operator[](utils::to_underlying(e));
}
const Stream &operator[](E e) const
{
- return std::array<class Stream, N>::operator[](index(e));
+ return std::array<class Stream, N>::operator[](utils::to_underlying(e));
}
};
diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp
index f3e00ead..540a428e 100644
--- a/src/libcamera/stream.cpp
+++ b/src/libcamera/stream.cpp
@@ -433,7 +433,7 @@ std::ostream &operator<<(std::ostream &out, StreamRole role)
"Viewfinder",
};
- out << names[static_cast<std::underlying_type_t<StreamRole>>(role)];
+ out << names[utils::to_underlying(role)];
return out;
}