From c58bec935c3adffac9d99b1675a563d7f2e9ae04 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 25 Jun 2020 04:23:35 +0300 Subject: libcamera: utils: Add map_keys() function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a map_keys() function to the utils namespace to extract keys from a map. Signed-off-by: Laurent Pinchart [Niklas: change return type to std::vector instead of std::set] Signed-off-by: Niklas Söderlund Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- include/libcamera/internal/utils.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/libcamera') diff --git a/include/libcamera/internal/utils.h b/include/libcamera/internal/utils.h index 0953423e..8d026cc6 100644 --- a/include/libcamera/internal/utils.h +++ b/include/libcamera/internal/utils.h @@ -15,6 +15,7 @@ #include #include #include +#include #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) @@ -36,6 +37,15 @@ const char *basename(const char *path); char *secure_getenv(const char *name); std::string dirname(const std::string &path); +template +std::vector map_keys(const T &map) +{ + std::vector keys; + std::transform(map.begin(), map.end(), std::back_inserter(keys), + [](const auto &value) { return value.first; }); + return keys; +} + template unsigned int set_overlap(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) -- cgit v1.2.1