diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-10-24 00:45:32 +0300 |
---|---|---|
committer | Jacopo Mondi <jacopo@jmondi.org> | 2020-10-26 17:51:32 +0100 |
commit | 581bb274956fcf7e781384342e88cd8fa35b1336 (patch) | |
tree | 09bf5011b6f607c7d48e37cb5ad2809ca898815b /test/object.cpp | |
parent | c430d39d203488cf93ab4f12ff9eb8b3c6380212 (diff) |
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>
Diffstat (limited to 'test/object.cpp')
0 files changed, 0 insertions, 0 deletions