Message ID | 20250815123138.2213654-2-barnabas.pocze@ideasonboard.com |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
On Fri, Aug 15, 2025 at 02:31:37PM +0200, Barnabás Pőcze wrote: > Default the copy/move constructor/assignment operators so that > they are available if possible. This can allow more efficient > passing and construction of these objects. > > Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> > Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> > --- > changes in v2: none > --- > .../libcamera_templates/definition_functions.tmpl | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl > index 16d11c309..3a57a3c2c 100644 > --- a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl > +++ b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl > @@ -39,6 +39,12 @@ public: > {%- endfor %} > { > } > + > + {{struct.mojom_name}}(const {{struct.mojom_name}} &) = default; > + {{struct.mojom_name}} &operator=(const {{struct.mojom_name}} &) = default; > + {{struct.mojom_name}}({{struct.mojom_name}} &&) = default; > + {{struct.mojom_name}} &operator=({{struct.mojom_name}} &&) = default; > + ~{{struct.mojom_name}}() = default; We usually declare them in this order: {{struct.mojom_name}}(const {{struct.mojom_name}} &) = default; {{struct.mojom_name}}({{struct.mojom_name}} &&) = default; ~{{struct.mojom_name}}() = default; {{struct.mojom_name}} &operator=(const {{struct.mojom_name}} &) = default; {{struct.mojom_name}} &operator=({{struct.mojom_name}} &&) = default; Do we need to explicitly default the destructor, won't the compiler do it ? And isn't it the case for the copy and move constructors/assignment operators as well actually ? I'm not sure to see what this patch brings, it's already possible to copy and move instances of the IPA structures as far as I can see. > #endif > > {% for field in struct.fields %}
2025. 08. 15. 16:57 keltezéssel, Laurent Pinchart írta: > On Fri, Aug 15, 2025 at 02:31:37PM +0200, Barnabás Pőcze wrote: >> Default the copy/move constructor/assignment operators so that >> they are available if possible. This can allow more efficient >> passing and construction of these objects. >> >> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> >> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> >> --- >> changes in v2: none >> --- >> .../libcamera_templates/definition_functions.tmpl | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl >> index 16d11c309..3a57a3c2c 100644 >> --- a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl >> +++ b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl >> @@ -39,6 +39,12 @@ public: >> {%- endfor %} >> { >> } >> + >> + {{struct.mojom_name}}(const {{struct.mojom_name}} &) = default; >> + {{struct.mojom_name}} &operator=(const {{struct.mojom_name}} &) = default; >> + {{struct.mojom_name}}({{struct.mojom_name}} &&) = default; >> + {{struct.mojom_name}} &operator=({{struct.mojom_name}} &&) = default; >> + ~{{struct.mojom_name}}() = default; > > We usually declare them in this order: > > {{struct.mojom_name}}(const {{struct.mojom_name}} &) = default; > {{struct.mojom_name}}({{struct.mojom_name}} &&) = default; > > ~{{struct.mojom_name}}() = default; > > {{struct.mojom_name}} &operator=(const {{struct.mojom_name}} &) = default; > {{struct.mojom_name}} &operator=({{struct.mojom_name}} &&) = default; > > Do we need to explicitly default the destructor, won't the compiler do > it ? And isn't it the case for the copy and move constructors/assignment > operators as well actually ? I'm not sure to see what this patch brings, > it's already possible to copy and move instances of the IPA structures > as far as I can see. Ahh, you're right... sorry I made a mistake while testing. All of them should already be implicitly generated. So this patch changes nothing, just makes that explicit. Let's ignore it. Regards, Barnabás Pőcze > >> #endif >> >> {% for field in struct.fields %} >
diff --git a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl index 16d11c309..3a57a3c2c 100644 --- a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl +++ b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl @@ -39,6 +39,12 @@ public: {%- endfor %} { } + + {{struct.mojom_name}}(const {{struct.mojom_name}} &) = default; + {{struct.mojom_name}} &operator=(const {{struct.mojom_name}} &) = default; + {{struct.mojom_name}}({{struct.mojom_name}} &&) = default; + {{struct.mojom_name}} &operator=({{struct.mojom_name}} &&) = default; + ~{{struct.mojom_name}}() = default; #endif {% for field in struct.fields %}