| Message ID | 20260120144431.264758-1-barnabas.pocze@ideasonboard.com |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
On Tue, Jan 20, 2026 at 03:44:31PM +0100, Barnabás Pőcze wrote: > For example, `std::span` does not have a `const_iterator` typedef before > C++23, so compilation fails. Simply use `auto`, the `const` qualifier on > the `items` variable should already ensure that, if one exists, a "const" > iterator will be used. What will be used with C++20, std::span::iterator ? I'm surprised that C++20 doesn't have a const_iterator for std::span, but as std::span<const T>::iterator is not mutable, I see no issue with this patch. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> > --- > include/libcamera/base/utils.h | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h > index 0b7407f77..2cb8e0a88 100644 > --- a/include/libcamera/base/utils.h > +++ b/include/libcamera/base/utils.h > @@ -110,8 +110,7 @@ std::string join(const Container &items, const std::string &sep, UnaryOp op) > std::ostringstream ss; > bool first = true; > > - for (typename Container::const_iterator it = std::begin(items); > - it != std::end(items); ++it) { > + for (auto it = std::begin(items); it != std::end(items); ++it) { > if (!first) > ss << sep; > else > @@ -129,8 +128,7 @@ std::string join(const Container &items, const std::string &sep) > std::ostringstream ss; > bool first = true; > > - for (typename Container::const_iterator it = std::begin(items); > - it != std::end(items); ++it) { > + for (auto it = std::begin(items); it != std::end(items); ++it) { > if (!first) > ss << sep; > else
diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h index 0b7407f77..2cb8e0a88 100644 --- a/include/libcamera/base/utils.h +++ b/include/libcamera/base/utils.h @@ -110,8 +110,7 @@ std::string join(const Container &items, const std::string &sep, UnaryOp op) std::ostringstream ss; bool first = true; - for (typename Container::const_iterator it = std::begin(items); - it != std::end(items); ++it) { + for (auto it = std::begin(items); it != std::end(items); ++it) { if (!first) ss << sep; else @@ -129,8 +128,7 @@ std::string join(const Container &items, const std::string &sep) std::ostringstream ss; bool first = true; - for (typename Container::const_iterator it = std::begin(items); - it != std::end(items); ++it) { + for (auto it = std::begin(items); it != std::end(items); ++it) { if (!first) ss << sep; else
For example, `std::span` does not have a `const_iterator` typedef before C++23, so compilation fails. Simply use `auto`, the `const` qualifier on the `items` variable should already ensure that, if one exists, a "const" iterator will be used. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> --- include/libcamera/base/utils.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)