mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-19 10:25:05 +03:00
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>
This commit is contained in:
parent
9c6d32fcf3
commit
cd04b9a96c
2 changed files with 3 additions and 3 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue