From 6a50c960be774b44a32f566f1f485cf800cc0527 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 23 Feb 2024 16:55:15 +0200 Subject: libcamera: utils: Add to_underlying() helper function C++23 has a std::to_underlying() helper function that converts an enumeration value to its underlying type. Add a compatible implementation to the libcamera::utils namespace. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Naushir Patuck --- src/libcamera/base/utils.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/libcamera') diff --git a/src/libcamera/base/utils.cpp b/src/libcamera/base/utils.cpp index 3b73b442..2f4c3177 100644 --- a/src/libcamera/base/utils.cpp +++ b/src/libcamera/base/utils.cpp @@ -521,6 +521,16 @@ double strtod(const char *__restrict nptr, char **__restrict endptr) #endif } +/** + * \fn to_underlying(Enum e) + * \brief Convert an enumeration to its underlygin type + * \param[in] e Enumeration value to convert + * + * This function is equivalent to the C++23 std::to_underlying(). + * + * \return The value of e converted to its underlying type + */ + } /* namespace utils */ #ifndef __DOXYGEN__ -- cgit v1.2.1