[v2,2/2] libcamera: utils: StringSplitter: Add `operator==`
diff mbox series

Message ID 20241205092258.1058077-2-pobrn@protonmail.com
State Accepted
Commit 737fb452fc3bb8a8513ddbf527f4836b9d32d2a5
Headers show
Series
  • [v2,1/2] libcamera: utils: StringSplitter: Inline some trivial methods
Related show

Commit Message

Barnabás Pőcze Dec. 5, 2024, 9:23 a.m. UTC
If `cpp_debugstl` is enabled in the build configuration, then
libstdc++ will try to use `==` on operators in certain cases
to carry out extra checks. This leads to build failures because
`StringSplitter::iterator` has no `operator==`.

Implement `operator==`, and express `operator!=` in terms of it.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
---
 include/libcamera/base/utils.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Dec. 5, 2024, 8:28 p.m. UTC | #1
Hi Barnabás,

Thank you for the patch.

On Thu, Dec 05, 2024 at 09:23:06AM +0000, Barnabás Pőcze wrote:
> If `cpp_debugstl` is enabled in the build configuration, then
> libstdc++ will try to use `==` on operators in certain cases
> to carry out extra checks. This leads to build failures because
> `StringSplitter::iterator` has no `operator==`.
> 
> Implement `operator==`, and express `operator!=` in terms of it.
> 
> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Could I ask you to have a look at enabling cpp_debugstl in CI ? I think
you should have the necessary permissions to use the runners on
gitlab.fdo, so testing should only be a matter of cloning the libcamera
and libcamera-ci tress in your user namespace, pointing the libcamera CI
configuration to libcamera-ci, and giving it a try. You can send patches
for the CI to this list, with a [libcamera-ci] or similar prefix.

> ---
>  include/libcamera/base/utils.h | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h
> index c4a06660..780aeda6 100644
> --- a/include/libcamera/base/utils.h
> +++ b/include/libcamera/base/utils.h
> @@ -205,9 +205,14 @@ public:
>  		iterator &operator++();
>  		std::string operator*() const;
>  
> +		bool operator==(const iterator &other) const
> +		{
> +			return pos_ == other.pos_;
> +		}
> +
>  		bool operator!=(const iterator &other) const
>  		{
> -			return pos_ != other.pos_;
> +			return !(*this == other);
>  		}
>  
>  	private:

Patch
diff mbox series

diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h
index c4a06660..780aeda6 100644
--- a/include/libcamera/base/utils.h
+++ b/include/libcamera/base/utils.h
@@ -205,9 +205,14 @@  public:
 		iterator &operator++();
 		std::string operator*() const;
 
+		bool operator==(const iterator &other) const
+		{
+			return pos_ == other.pos_;
+		}
+
 		bool operator!=(const iterator &other) const
 		{
-			return pos_ != other.pos_;
+			return !(*this == other);
 		}
 
 	private: