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 <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
This commit is contained in:
Laurent Pinchart
2024-02-23 16:55:15 +02:00
parent 059bbcdc34
commit 6a50c960be
2 changed files with 16 additions and 0 deletions
+6
View File
@@ -369,6 +369,12 @@ decltype(auto) abs_diff(const T &a, const T &b)
double strtod(const char *__restrict nptr, char **__restrict endptr);
template<class Enum>
constexpr std::underlying_type_t<Enum> to_underlying(Enum e) noexcept
{
return static_cast<std::underlying_type_t<Enum>>(e);
}
} /* namespace utils */
#ifndef __DOXYGEN__