summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarnabás Pőcze <barnabas.pocze@ideasonboard.com>2025-03-19 16:56:11 +0100
committerBarnabás Pőcze <barnabas.pocze@ideasonboard.com>2025-04-01 13:57:45 +0200
commit5646307b71dbfeb3864788c8a57957c594a45975 (patch)
treec64ab5054efec3d69c2478320de58fee23d30aeb
parent7dd548f678bfcac435ae0f790c33f99b6fb2c5c4 (diff)
libcamera: base: bound_method: Simplify `invokePack()`
Use `if constexpr` instead of SFINAE to handle return values of type `void`. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r--include/libcamera/base/bound_method.h20
1 files changed, 7 insertions, 13 deletions
diff --git a/include/libcamera/base/bound_method.h b/include/libcamera/base/bound_method.h
index dd3488ee..507c320d 100644
--- a/include/libcamera/base/bound_method.h
+++ b/include/libcamera/base/bound_method.h
@@ -98,21 +98,15 @@ public:
using PackType = BoundMethodPack<R, Args...>;
private:
- template<std::size_t... I, typename T = R>
- std::enable_if_t<!std::is_void<T>::value, void>
- invokePack(BoundMethodPackBase *pack, std::index_sequence<I...>)
+ template<std::size_t... I>
+ void invokePack(BoundMethodPackBase *pack, std::index_sequence<I...>)
{
- PackType *args = static_cast<PackType *>(pack);
- args->ret_ = invoke(std::get<I>(args->args_)...);
- }
+ [[maybe_unused]] auto *args = static_cast<PackType *>(pack);
- template<std::size_t... I, typename T = R>
- std::enable_if_t<std::is_void<T>::value, void>
- invokePack(BoundMethodPackBase *pack, std::index_sequence<I...>)
- {
- /* args is effectively unused when the sequence I is empty. */
- PackType *args [[gnu::unused]] = static_cast<PackType *>(pack);
- invoke(std::get<I>(args->args_)...);
+ if constexpr (!std::is_void_v<R>)
+ args->ret_ = invoke(std::get<I>(args->args_)...);
+ else
+ invoke(std::get<I>(args->args_)...);
}
public: