[libcamera-devel] [PATCH] libcamera: v4l2_device: Fix operator= definition

Laurent Pinchart laurent.pinchart at ideasonboard.com
Sun Jan 27 17:09:25 CET 2019


Hi Jacopo,

On Sun, Jan 27, 2019 at 03:41:52PM +0100, Jacopo Mondi wrote:
> While the C++ allows the redefinition of operator= to return an
> arbitrary type, it is customary to return a reference to the assigned
> value type.

It's a bit more than customary, as you wouldn't be able to write

	a = b = c;

otherwise. In any case the operator= can't be used if you declarate a
deleted operator, regardless of the return type, so this is fine.

> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>

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

> ---
>  src/libcamera/include/v4l2_device.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h
> index 413bb7f..c67ebbf 100644
> --- a/src/libcamera/include/v4l2_device.h
> +++ b/src/libcamera/include/v4l2_device.h
> @@ -62,7 +62,7 @@ public:
>  	V4L2Device(const V4L2Device &) = delete;
>  	~V4L2Device();
> 
> -	void operator=(const V4L2Device &) = delete;
> +	V4L2Device &operator=(const V4L2Device &) = delete;
> 
>  	int open();
>  	bool isOpen() const;

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list