@@ -16,6 +16,8 @@
{% if has_map %}#include <map>{% endif %}
{% if has_string %}#include <string>{% endif %}
+#include <type_traits>
+#include <utility>
{% if has_array %}#include <vector>{% endif %}
#include <libcamera/controls.h>
@@ -28,14 +28,21 @@ public:
#ifndef __DOXYGEN__
{{struct.mojom_name}}() = default;
+ template<
+ {%- for field in struct.fields %}
+ typename T{{loop.index}} = {{field|name}},
+ {%- endfor %}
+ {%- for field in struct.fields %}
+ std::enable_if_t<std::is_convertible_v<T{{loop.index}}&&, {{field|name}}>> * = nullptr{{"," if not loop.last}}
+ {%- endfor %}
+ >
{{struct.mojom_name}}(
{%- for field in struct.fields -%}
-{{"const " if not field|is_pod}}{{field|name}} {{"&" if not field|is_pod}}_{{field.mojom_name}}{{", " if not loop.last}}
+ T{{loop.index}} &&_{{field.mojom_name}}{{ ", " if not loop.last }}
{%- endfor -%}
)
- :
-{%- for field in struct.fields -%}
-{{" " if loop.first}}{{field.mojom_name}}(_{{field.mojom_name}}){{", " if not loop.last}}
+{%- for field in struct.fields %}
+ {{": " if loop.first else ", "}}{{field.mojom_name}}(std::forward<T{{loop.index}}>(_{{field.mojom_name}}))
{%- endfor %}
{
}
@@ -16,6 +16,8 @@
{% if has_map %}#include <map>{% endif %}
{% if has_string %}#include <string>{% endif %}
+#include <type_traits>
+#include <utility>
{% if has_array %}#include <vector>{% endif %}
#include <libcamera/base/flags.h>