From 6cbdc2859963e17bc897a4022f1d68170477d888 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 26 Oct 2020 21:15:11 +0200 Subject: libcamera: Use helper variable template for type traits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit C++17 introduces helper variable templates for type traits, allowing shortening std::is_foo::value to std::is_foo_v. Use them through the code base. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- include/libcamera/bound_method.h | 2 +- include/libcamera/controls.h | 12 +++++----- include/libcamera/object.h | 2 +- include/libcamera/signal.h | 4 ++-- include/libcamera/span.h | 48 ++++++++++++++++++++-------------------- 5 files changed, 34 insertions(+), 34 deletions(-) (limited to 'include') diff --git a/include/libcamera/bound_method.h b/include/libcamera/bound_method.h index 95a95653..feac51da 100644 --- a/include/libcamera/bound_method.h +++ b/include/libcamera/bound_method.h @@ -63,7 +63,7 @@ public: } virtual ~BoundMethodBase() = default; - template::value> * = nullptr> + template> * = nullptr> bool match(T *obj) { return obj == obj_; } bool match(Object *object) { return object == object_; } diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 3b7f3347..dc549a92 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -98,7 +98,7 @@ public: #ifndef __DOXYGEN__ template::value && details::control_type::value && - !std::is_same>::value, + !std::is_same_v>, std::nullptr_t> = nullptr> ControlValue(const T &value) : type_(ControlTypeNone), numElements_(0) @@ -108,7 +108,7 @@ public: } template::value || - std::is_same>::value, + std::is_same_v>, std::nullptr_t> = nullptr> #else template @@ -142,7 +142,7 @@ public: #ifndef __DOXYGEN__ template::value && - !std::is_same>::value, + !std::is_same_v>, std::nullptr_t> = nullptr> T get() const { @@ -153,7 +153,7 @@ public: } template::value || - std::is_same>::value, + std::is_same_v>, std::nullptr_t> = nullptr> #else template @@ -170,7 +170,7 @@ public: #ifndef __DOXYGEN__ template::value && - !std::is_same>::value, + !std::is_same_v>, std::nullptr_t> = nullptr> void set(const T &value) { @@ -179,7 +179,7 @@ public: } template::value || - std::is_same>::value, + std::is_same_v>, std::nullptr_t> = nullptr> #else template diff --git a/include/libcamera/object.h b/include/libcamera/object.h index a1882f05..423208db 100644 --- a/include/libcamera/object.h +++ b/include/libcamera/object.h @@ -32,7 +32,7 @@ public: void postMessage(std::unique_ptr msg); template::value> * = nullptr> + typename std::enable_if_t> * = nullptr> R invokeMethod(R (T::*func)(FuncArgs...), ConnectionType type, Args... args) { diff --git a/include/libcamera/signal.h b/include/libcamera/signal.h index 5bcd7a77..46d917d5 100644 --- a/include/libcamera/signal.h +++ b/include/libcamera/signal.h @@ -44,7 +44,7 @@ public: } #ifndef __DOXYGEN__ - template::value> * = nullptr> + template> * = nullptr> void connect(T *obj, R (T::*func)(Args...), ConnectionType type = ConnectionTypeAuto) { @@ -52,7 +52,7 @@ public: SignalBase::connect(new BoundMethodMember(obj, object, func, type)); } - template::value> * = nullptr> + template> * = nullptr> #else template #endif diff --git a/include/libcamera/span.h b/include/libcamera/span.h index 91e9f974..d720adb8 100644 --- a/include/libcamera/span.h +++ b/include/libcamera/span.h @@ -125,8 +125,8 @@ public: template constexpr Span(element_type (&arr)[N], - std::enable_if_t (*)[], - element_type (*)[]>::value && + std::enable_if_t (*)[], + element_type (*)[]> && N == Extent, std::nullptr_t> = nullptr) noexcept : data_(arr) @@ -135,8 +135,8 @@ public: template constexpr Span(std::array &arr, - std::enable_if_t (*)[], - element_type (*)[]>::value && + std::enable_if_t (*)[], + element_type (*)[]> && N == Extent, std::nullptr_t> = nullptr) noexcept : data_(arr.data()) @@ -145,8 +145,8 @@ public: template constexpr Span(const std::array &arr, - std::enable_if_t (*)[], - element_type (*)[]>::value && + std::enable_if_t (*)[], + element_type (*)[]> && N == Extent, std::nullptr_t> = nullptr) noexcept : data_(arr.data()) @@ -157,9 +157,9 @@ public: explicit constexpr Span(Container &cont, std::enable_if_t::value && !details::is_array::value && - !std::is_array::value && - std::is_convertible (*)[], - element_type (*)[]>::value, + !std::is_array_v && + std::is_convertible_v (*)[], + element_type (*)[]>, std::nullptr_t> = nullptr) : data_(utils::data(cont)) { @@ -169,9 +169,9 @@ public: explicit constexpr Span(const Container &cont, std::enable_if_t::value && !details::is_array::value && - !std::is_array::value && - std::is_convertible (*)[], - element_type (*)[]>::value, + !std::is_array_v && + std::is_convertible_v (*)[], + element_type (*)[]>, std::nullptr_t> = nullptr) : data_(utils::data(cont)) { @@ -180,7 +180,7 @@ public: template explicit constexpr Span(const Span &s, - std::enable_if_t::value && + std::enable_if_t && N == Extent, std::nullptr_t> = nullptr) noexcept : data_(s.data()) @@ -293,8 +293,8 @@ public: template constexpr Span(element_type (&arr)[N], - std::enable_if_t (*)[], - element_type (*)[]>::value, + std::enable_if_t (*)[], + element_type (*)[]>, std::nullptr_t> = nullptr) noexcept : data_(arr), size_(N) { @@ -302,8 +302,8 @@ public: template constexpr Span(std::array &arr, - std::enable_if_t (*)[], - element_type (*)[]>::value, + std::enable_if_t (*)[], + element_type (*)[]>, std::nullptr_t> = nullptr) noexcept : data_(utils::data(arr)), size_(N) { @@ -319,9 +319,9 @@ public: constexpr Span(Container &cont, std::enable_if_t::value && !details::is_array::value && - !std::is_array::value && - std::is_convertible (*)[], - element_type (*)[]>::value, + !std::is_array_v && + std::is_convertible_v (*)[], + element_type (*)[]>, std::nullptr_t> = nullptr) : data_(utils::data(cont)), size_(utils::size(cont)) { @@ -331,9 +331,9 @@ public: constexpr Span(const Container &cont, std::enable_if_t::value && !details::is_array::value && - !std::is_array::value && - std::is_convertible (*)[], - element_type (*)[]>::value, + !std::is_array_v && + std::is_convertible_v (*)[], + element_type (*)[]>, std::nullptr_t> = nullptr) : data_(utils::data(cont)), size_(utils::size(cont)) { @@ -341,7 +341,7 @@ public: template constexpr Span(const Span &s, - std::enable_if_t::value, + std::enable_if_t, std::nullptr_t> = nullptr) noexcept : data_(s.data()), size_(s.size()) { -- cgit v1.2.1