libcamera/include/libcamera
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
..
bound_method.h libcamera: Remove unneeded semicolons 2019-11-08 20:37:47 +02:00
buffer.h libcamera: buffer: Add const accessor to Buffer planes 2019-11-20 21:47:43 +02:00
camera.h libcamera: camera: Remove explicit stream to buffer map in requestCompleted signal 2019-11-19 18:30:26 +01:00
camera_manager.h libcamera: camera_manager: Construct CameraManager instances manually 2019-08-19 19:07:45 +03:00
control_ids.h.in libcamera: control_ids: Generate map of all supported controls 2019-10-13 20:37:24 +03:00
controls.h libcamera: controls: Store reference to the InfoMap 2019-11-20 21:47:41 +02:00
event_dispatcher.h libcamera: event_dispatcher: Add interrupt() function 2019-01-23 18:51:56 +02:00
event_notifier.h libcamera: Add parent argument to constructors of Object-derived classes 2019-08-17 18:47:17 +03:00
gen-header.sh libcamera: controls: Auto-generate control_ids.h and control_ids.cpp 2019-10-05 20:02:51 +03:00
geometry.h libcamera: geometry: SizeRange: Add contains() 2019-06-19 02:23:01 +02:00
logging.h libcamera: logging: add syslog, stream, and nowhere logging targets 2019-07-17 14:36:35 +09:00
meson.build libcamera: Define a PixelFormat type for application-facing formats 2019-10-28 13:07:50 +02:00
object.h libcamera: object: Support reference arguments in invokeMethod() 2020-01-03 16:29:02 +02:00
pixelformats.h libcamera: Define a PixelFormat type for application-facing formats 2019-10-28 13:07:50 +02:00
request.h libcamera: request: Add metadata information 2019-10-10 21:39:53 +03:00
signal.h libcamera: signal: Specify connection type for signals 2019-10-29 16:44:43 +02:00
stream.h libcamera: stream: Use the newly defined PixelFormat 2019-10-28 13:08:08 +02:00
timer.h libcamera: Standardise on C compatibility headers 2019-10-23 17:39:39 +03:00
version.h.in libcamera: Rework automatic version generation to avoid rebuilds 2019-07-09 12:34:10 +03:00