summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-02-14 16:49:31 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-03-06 18:10:19 +0200
commitcd04b9a96c7643f92f6b555b594739e0ddf0406a (patch)
tree9f823d10d07dec8698d68d5e84df47a22ffc00e8
parent9c6d32fcf3198cc83cff6af3c9393e94c88bf9b9 (diff)
libcamera: controls: Decouple control and value type in ControlList::set()
The ControlList::set() method takes a reference to a Control<T>, and requires the value to be a reference to T. This prevents the set() method from being used with value types that are convertible to T, and in particular with std::array or std::vector value types when the Control type is a Span<> to support array controls. Fix this by decoupling the control type and value type in the template parameters. The compiler will still catch invalid conversions, including cases where the constructor of type T from the value type is explicit. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r--include/libcamera/controls.h4
-rw-r--r--src/libcamera/controls.cpp2
2 files changed, 3 insertions, 3 deletions
diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
index 9f8a9031..9d93064c 100644
--- a/include/libcamera/controls.h
+++ b/include/libcamera/controls.h
@@ -223,8 +223,8 @@ public:
return val->get<T>();
}
- template<typename T>
- void set(const Control<T> &ctrl, const T &value)
+ template<typename T, typename V>
+ void set(const Control<T> &ctrl, const V &value)
{
ControlValue *val = find(ctrl.id());
if (!val)
diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
index f632d60a..a136ebd2 100644
--- a/src/libcamera/controls.cpp
+++ b/src/libcamera/controls.cpp
@@ -735,7 +735,7 @@ bool ControlList::contains(unsigned int id) const
*/
/**
- * \fn template<typename T> void ControlList::set(const Control<T> &ctrl, const T &value)
+ * \fn template<typename T, typename V> void ControlList::set(const Control<T> &ctrl, const V &value)
* \brief Set the control \a ctrl value to \a value
* \param[in] ctrl The control
* \param[in] value The control value