From b2710e8c3621cb5181f3f31c8856d4823666f891 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 14 Feb 2020 17:02:18 +0200 Subject: libcamera: controls: Move ControlValue constructor to controls.h To avoid defining all specializations of the ControlValue constructor manually, move the definition of those functions to controls.h and turn them into a single template function. The default constructor is still kept in controls.cpp. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- include/libcamera/controls.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 39e24043..dfe69916 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -55,9 +55,13 @@ class ControlValue { public: ControlValue(); - ControlValue(bool value); - ControlValue(int32_t value); - ControlValue(int64_t value); + + template + ControlValue(T value) + : type_(details::control_type>::value) + { + *reinterpret_cast(&bool_) = value; + } ControlType type() const { return type_; } bool isNone() const { return type_ == ControlTypeNone; } -- cgit v1.2.1