libcamera/include
Laurent Pinchart 1acad98f7d libcamera: object: Support reference arguments in invokeMethod()
Invoking a method that takes a reference argument with
Object::invokeMethod() results in a compilation error:

../test/object-invoke.cpp:131:11: error: no matching member function for call to 'invokeMethod'
                object_.invokeMethod(&InvokedObject::methodWithReference,
                ~~~~~~~~^~~~~~~~~~~~
../include/libcamera/object.h:33:7: note: candidate template ignored: deduced conflicting types for parameter 'Args' (<const int &> vs. <int>)
        void invokeMethod(void (T::*func)(Args...), ConnectionType type, Args... args)

This is due to the fact that implicit type conversions (from value to
reference in this case) takes place after template argument type
deduction, during overload resolution. A similar issue would occur if
T::func took a long argument and invokeMethod() was called with an in
argument.

Fix this by specifying to sets of argument types in the invokeMethod()
template, one for the arguments to the invoked method, and one for the
arguments to invokeMethod() itself. The compiler can then first perform
type deduction separately, and implicit conversion in a second step.

Reported-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-01-03 16:29:02 +02:00
..
android include: android: Add SPDX tags 2019-08-12 10:34:13 +02:00
ipa ipa: Allow short-circuiting the ipa_context_ops 2019-11-20 21:48:05 +02:00
libcamera libcamera: object: Support reference arguments in invokeMethod() 2020-01-03 16:29:02 +02:00
linux include: linux: Update Linux headers readme to v5.2 2019-12-08 23:59:25 -05:00
meson.build libcamera: Move ipa includes to the same level as libcamera 2019-09-15 13:57:08 +03:00