mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-17 09:25:07 +03:00
libcamera: controls: Disable ControlValue<T> construction from unsupported T
The ControlValue<T> constructor for non-array values is a template function that participates in overload resolution for all T types that are not Span or std::string. Other T types that are not supported then result in a compilation error. This causes issues when calling an overloaded function that can accept both a ControlValue and a Span with an std::array<U> parameter. The first overload will be resolved using implicit construction of a ControlValue from the std::array<U>, while the second overload will be resolved using implicit construction of a Span<U> from the std::array<U>. This results in a compilation error due to an ambiguous function call. The first overload is invalid, selecting it would result in a compilation error in the ControlValue constructor, as the ControlValue<T> constructor doesn't support std::array<U> for type T. The compiler can't know about that, as overload resolution happens earlier. To fix it, we can disable the ControlValue<T> constructor for unsupported types T, moving the type check from compilation of the function to overload resolution. The constructor will not participate in overload resolution, and the call won't be ambiguous. The end result is the same for unsupported types, compilation will fail. Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
c430d39d20
commit
581bb27495
1 changed files with 1 additions and 0 deletions
|
@ -96,6 +96,7 @@ public:
|
|||
|
||||
#ifndef __DOXYGEN__
|
||||
template<typename T, typename std::enable_if_t<!details::is_span<T>::value &&
|
||||
details::control_type<T>::value &&
|
||||
!std::is_same<std::string, std::remove_cv_t<T>>::value,
|
||||
std::nullptr_t> = nullptr>
|
||||
ControlValue(const T &value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue