[libcamera-devel] libcamera: span: Use default copy assignemnt operator

Message ID 20200929011850.13997-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit dcf2a8ce1026d13b16d5cba065dec5c9bb78a0a1
Headers show
Series
  • [libcamera-devel] libcamera: span: Use default copy assignemnt operator
Related show

Commit Message

Laurent Pinchart Sept. 29, 2020, 1:18 a.m. UTC
The custom implementation of the copy assignment operator is identical
to the one the compiler would generate. Replace it by the default.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 include/libcamera/span.h | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Comments

Paul Elder Sept. 29, 2020, 2:33 a.m. UTC | #1
Hi Laurent,

On Tue, Sep 29, 2020 at 04:18:50AM +0300, Laurent Pinchart wrote:
> The custom implementation of the copy assignment operator is identical
> to the one the compiler would generate. Replace it by the default.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  include/libcamera/span.h | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/include/libcamera/span.h b/include/libcamera/span.h
> index 738af6aca871..a53a80b81640 100644
> --- a/include/libcamera/span.h
> +++ b/include/libcamera/span.h
> @@ -188,12 +188,7 @@ public:
>  	}
>  
>  	constexpr Span(const Span &other) noexcept = default;
> -
> -	constexpr Span &operator=(const Span &other) noexcept
> -	{
> -		data_ = other.data_;
> -		return *this;
> -	}
> +	constexpr Span &operator=(const Span &other) noexcept = default;
>  
>  	constexpr iterator begin() const { return data(); }
>  	constexpr const_iterator cbegin() const { return begin(); }
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Niklas Söderlund Sept. 29, 2020, 5:20 a.m. UTC | #2
Hi Laurent,

Thanks for your work.

On 2020-09-29 04:18:50 +0300, Laurent Pinchart wrote:
> The custom implementation of the copy assignment operator is identical
> to the one the compiler would generate. Replace it by the default.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  include/libcamera/span.h | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/include/libcamera/span.h b/include/libcamera/span.h
> index 738af6aca871..a53a80b81640 100644
> --- a/include/libcamera/span.h
> +++ b/include/libcamera/span.h
> @@ -188,12 +188,7 @@ public:
>  	}
>  
>  	constexpr Span(const Span &other) noexcept = default;
> -
> -	constexpr Span &operator=(const Span &other) noexcept
> -	{
> -		data_ = other.data_;
> -		return *this;
> -	}
> +	constexpr Span &operator=(const Span &other) noexcept = default;
>  
>  	constexpr iterator begin() const { return data(); }
>  	constexpr const_iterator cbegin() const { return begin(); }
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/include/libcamera/span.h b/include/libcamera/span.h
index 738af6aca871..a53a80b81640 100644
--- a/include/libcamera/span.h
+++ b/include/libcamera/span.h
@@ -188,12 +188,7 @@  public:
 	}
 
 	constexpr Span(const Span &other) noexcept = default;
-
-	constexpr Span &operator=(const Span &other) noexcept
-	{
-		data_ = other.data_;
-		return *this;
-	}
+	constexpr Span &operator=(const Span &other) noexcept = default;
 
 	constexpr iterator begin() const { return data(); }
 	constexpr const_iterator cbegin() const { return begin(); }