Skip to content

Commit 7c88951

Browse files
committed
C++17: Replace some call_*() helpers with std::apply().
1 parent 025934b commit 7c88951

File tree

3 files changed

+4
-45
lines changed

3 files changed

+4
-45
lines changed

sigc++/adaptors/bind.h

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,7 @@ struct bind_functor : public adapts<T_functor>
150150
const auto t_end = internal::tuple_end<t_args_size - I_location>(t_args);
151151
const auto t_with_bound = std::tuple_cat(t_start, t_bound, t_end);
152152

153-
constexpr const auto seq =
154-
std::make_index_sequence<std::tuple_size<decltype(t_with_bound)>::value>();
155-
return call_functor_operator_parentheses(t_with_bound, seq);
153+
return std::apply(this->functor_, t_with_bound);
156154
}
157155

158156
/** Constructs a bind_functor object that binds an argument to the passed functor.
@@ -167,12 +165,6 @@ struct bind_functor : public adapts<T_functor>
167165
private:
168166
/// The arguments bound to the functor.
169167
std::tuple<bound_argument<T_bound>...> bound_;
170-
171-
template <typename T, std::size_t... Is>
172-
decltype(auto) call_functor_operator_parentheses(T&& tuple, std::index_sequence<Is...>)
173-
{
174-
return (this->functor_)(std::get<Is>(std::forward<T>(tuple))...);
175-
}
176168
};
177169

178170
/** Adaptor that binds argument(s) to the wrapped functor.
@@ -199,8 +191,7 @@ struct bind_functor<-1, T_functor, T_type...> : public adapts<T_functor>
199191
const auto t_bound = internal::tuple_transform_each<internal::TransformEachInvoker>(bound_);
200192
const auto t_with_bound = std::tuple_cat(t_args, t_bound);
201193

202-
constexpr auto seq = std::make_index_sequence<std::tuple_size<decltype(t_with_bound)>::value>();
203-
return call_functor_operator_parentheses(t_with_bound, seq);
194+
return std::apply(this->functor_, t_with_bound);
204195
}
205196

206197
/** Constructs a bind_functor object that binds an argument to the passed functor.
@@ -214,13 +205,6 @@ struct bind_functor<-1, T_functor, T_type...> : public adapts<T_functor>
214205

215206
/// The argument bound to the functor.
216207
std::tuple<bound_argument<T_type>...> bound_;
217-
218-
private:
219-
template <typename T, std::size_t... Is>
220-
decltype(auto) call_functor_operator_parentheses(T&& tuple, std::index_sequence<Is...>)
221-
{
222-
return (this->functor_)(std::get<Is>(std::forward<T>(tuple))...);
223-
}
224208
};
225209

226210
#ifndef DOXYGEN_SHOULD_SKIP_THIS

sigc++/adaptors/hide.h

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,28 +102,13 @@ struct hide_functor : public adapts<T_functor>
102102
const auto t_end = internal::tuple_end<size - index_ignore - 1>(t);
103103
const auto t_used = std::tuple_cat(t_start, t_end);
104104

105-
constexpr auto size_used = size - 1;
106-
107-
// TODO: Remove these? They are just here as a sanity check.
108-
static_assert(std::tuple_size<decltype(t_used)>::value == size_used, "Unexpected t_used size.");
109-
110-
const auto seq = std::make_index_sequence<size_used>();
111-
return call_functor_operator_parentheses(t_used, seq);
105+
return std::apply(this->functor_, t_used);
112106
}
113107

114108
/** Constructs a hide_functor object that adds a dummy parameter to the passed functor.
115109
* @param func Functor to invoke from operator()().
116110
*/
117111
explicit hide_functor(const T_functor& func) : adapts<T_functor>(func) {}
118-
119-
private:
120-
// TODO_variadic: Replace this with std::experimental::apply() if that becomes standard
121-
// C++, or add our own implementation, to avoid code duplication.
122-
template <typename T_tuple, std::size_t... Is>
123-
decltype(auto) call_functor_operator_parentheses(T_tuple& tuple, std::index_sequence<Is...>)
124-
{
125-
return this->functor_.template operator()(std::get<Is>(tuple)...);
126-
}
127112
};
128113

129114
#ifndef DOXYGEN_SHOULD_SKIP_THIS

sigc++/signal.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,7 @@ struct signal_emit
246246
*/
247247
T_return operator()(const slot_type& slot) const
248248
{
249-
const auto seq = std::make_index_sequence<std::tuple_size<decltype(a_)>::value>();
250-
return call_call_type_operator_parentheses_with_tuple(slot, a_, seq);
249+
return std::apply(slot, a_);
251250
}
252251

253252
/** Executes a list of slots using an accumulator of type @e T_accumulator.
@@ -274,15 +273,6 @@ struct signal_emit
274273

275274
private:
276275
std::tuple<type_trait_take_t<T_arg>...> a_;
277-
278-
// TODO_variadic: Replace this with std::experimental::apply() if that becomes standard
279-
// C++, or add our own implementation, to avoid code duplication.
280-
template <std::size_t... Is>
281-
decltype(auto) call_call_type_operator_parentheses_with_tuple(
282-
const slot_type& slot, const std::tuple<T_arg...>& tuple, std::index_sequence<Is...>) const
283-
{
284-
return (slot)(std::get<Is>(tuple)...);
285-
}
286276
};
287277

288278
/** Abstracts signal emission.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy