From e497c86718bd2d158372ab59721e79032c84eb0d Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Wed, 21 Sep 2016 09:18:03 +0200 Subject: C++17: Replace call_*() helpers with std::apply(). --- sigc++/adaptors/bind.h | 20 ++------------------ sigc++/adaptors/hide.h | 17 +---------------- sigc++/signal.h | 12 +----------- 3 files changed, 4 insertions(+), 45 deletions(-) diff --git a/sigc++/adaptors/bind.h b/sigc++/adaptors/bind.h index e93250b..0c281f0 100644 --- a/sigc++/adaptors/bind.h +++ b/sigc++/adaptors/bind.h @@ -151,9 +151,7 @@ struct bind_functor : public adapts const auto t_end = internal::tuple_end(t_args); const auto t_with_bound = std::tuple_cat(t_start, t_bound, t_end); - constexpr const auto seq = - std::make_index_sequence::value>(); - return call_functor_operator_parentheses(t_with_bound, seq); + return std::apply(this->functor_, t_with_bound); } /** Constructs a bind_functor object that binds an argument to the passed functor. @@ -168,12 +166,6 @@ struct bind_functor : public adapts private: /// The arguments bound to the functor. std::tuple...> bound_; - - template - decltype(auto) call_functor_operator_parentheses(T&& tuple, std::index_sequence) - { - return std::invoke(this->functor_, std::get(std::forward(tuple))...); - } }; /** Adaptor that binds argument(s) to the wrapped functor. @@ -200,8 +192,7 @@ public: const auto t_bound = internal::tuple_transform_each(bound_); const auto t_with_bound = std::tuple_cat(t_args, t_bound); - constexpr auto seq = std::make_index_sequence::value>(); - return call_functor_operator_parentheses(t_with_bound, seq); + return std::apply(this->functor, t_with_bound); } /** Constructs a bind_functor object that binds an argument to the passed functor. @@ -215,13 +206,6 @@ public: /// The argument bound to the functor. std::tuple...> bound_; - -private: - template - decltype(auto) call_functor_operator_parentheses(T&& tuple, std::index_sequence) - { - return std::invoke(this->functor_, std::get(std::forward(tuple))...); - } }; #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/sigc++/adaptors/hide.h b/sigc++/adaptors/hide.h index a6acdf3..8d9d145 100644 --- a/sigc++/adaptors/hide.h +++ b/sigc++/adaptors/hide.h @@ -102,28 +102,13 @@ struct hide_functor : public adapts const auto t_end = internal::tuple_end(t); const auto t_used = std::tuple_cat(t_start, t_end); - constexpr auto size_used = size - 1; - - // TODO: Remove these? They are just here as a sanity check. - static_assert(std::tuple_size::value == size_used, "Unexpected t_used size."); - - const auto seq = std::make_index_sequence(); - return call_functor_operator_parentheses(t_used, seq); + return std::apply(this->functor_, t_used); } /** Constructs a hide_functor object that adds a dummy parameter to the passed functor. * @param func Functor to invoke from operator()(). */ explicit hide_functor(const T_functor& func) : adapts(func) {} - -private: - // TODO_variadic: Replace this with std::experimental::apply() if that becomes standard - // C++, or add our own implementation, to avoid code duplication. - template - decltype(auto) call_functor_operator_parentheses(T_tuple& tuple, std::index_sequence) - { - return std::invoke(this->functor_, std::get(tuple)...); - } }; #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/sigc++/signal.h b/sigc++/signal.h index e6a6090..6b26cac 100644 --- a/sigc++/signal.h +++ b/sigc++/signal.h @@ -246,8 +246,7 @@ struct signal_emit */ T_return operator()(const slot_type& slot) const { - const auto seq = std::make_index_sequence::value>(); - return call_call_type_operator_parentheses_with_tuple(slot, a_, seq); + return std::apply(slot, a_); } /** Executes a list of slots using an accumulator of type @e T_accumulator. @@ -274,15 +273,6 @@ struct signal_emit private: std::tuple...> a_; - - // TODO_variadic: Replace this with std::experimental::apply() if that becomes standard - // C++, or add our own implementation, to avoid code duplication. - template - decltype(auto) call_call_type_operator_parentheses_with_tuple( - const slot_type& slot, const std::tuple& tuple, std::index_sequence) const - { - return std::invoke(slot, std::get(tuple)...); - } }; /** Abstracts signal emission. -- cgit v1.2.1