From 7216c6a9bb815ca9d0b4247f8e04d87e4ac85fa2 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 19 Jan 2020 20:28:39 +0200 Subject: libcamera: bound_method: Use std::index_sequence MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that we're using C++-14, replace the manual implementation of std::integer_sequence with std::index_sequence, a specialization of std::integer_sequence with the integer type equal to std::size_t. The template parameter S that denotes a sequence is replaced with I to align with the usage examples of cppreference.com. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- include/libcamera/bound_method.h | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) (limited to 'include') diff --git a/include/libcamera/bound_method.h b/include/libcamera/bound_method.h index ca501493..7ffd2e42 100644 --- a/include/libcamera/bound_method.h +++ b/include/libcamera/bound_method.h @@ -10,6 +10,7 @@ #include #include #include +#include namespace libcamera { @@ -71,25 +72,6 @@ public: virtual void invokePack(BoundMethodPackBase *pack) = 0; protected: -#ifndef __DOXYGEN__ - /* - * This is a cheap partial implementation of std::integer_sequence<> - * from C++14. - */ - template - struct sequence { - }; - - template - struct generator : generator { - }; - - template - struct generator<0, S...> { - typedef sequence type; - }; -#endif - bool activatePack(std::shared_ptr pack, bool deleteMethod); @@ -107,11 +89,11 @@ public: using PackType = BoundMethodPack; private: - template - void invokePack(BoundMethodPackBase *pack, BoundMethodBase::sequence) + template + void invokePack(BoundMethodPackBase *pack, std::index_sequence) { PackType *args = static_cast(pack); - args->ret_ = invoke(std::get(args->args_)...); + args->ret_ = invoke(std::get(args->args_)...); } public: @@ -120,7 +102,7 @@ public: void invokePack(BoundMethodPackBase *pack) override { - invokePack(pack, typename BoundMethodBase::generator::type()); + invokePack(pack, std::make_index_sequence{}); } virtual R activate(Args... args, bool deleteMethod = false) = 0; @@ -134,12 +116,12 @@ public: using PackType = BoundMethodPack; private: - template - void invokePack(BoundMethodPackBase *pack, BoundMethodBase::sequence) + template + void invokePack(BoundMethodPackBase *pack, std::index_sequence) { - /* args is effectively unused when the sequence S is empty. */ + /* args is effectively unused when the sequence I is empty. */ PackType *args [[gnu::unused]] = static_cast(pack); - invoke(std::get(args->args_)...); + invoke(std::get(args->args_)...); } public: @@ -148,7 +130,7 @@ public: void invokePack(BoundMethodPackBase *pack) override { - invokePack(pack, typename BoundMethodBase::generator::type()); + invokePack(pack, std::make_index_sequence{}); } virtual void activate(Args... args, bool deleteMethod = false) = 0; -- cgit v1.2.1