[libsigc++2/variadic_bind2: 64/68] tuple_transform_each(): Avoid use of std::make_tuple().
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsigc++2/variadic_bind2: 64/68] tuple_transform_each(): Avoid use of std::make_tuple().
- Date: Tue, 1 Mar 2016 21:49:06 +0000 (UTC)
commit 97d8a5ccfcbd6304d15e118548e507ff1a102b19
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Feb 19 12:39:50 2016 +0100
tuple_transform_each(): Avoid use of std::make_tuple().
To preserve std::ref()ed elements.
test_bind now builds and passes.
sigc++/tuple_transform_each.h | 20 +++++++++++---------
1 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/sigc++/tuple_transform_each.h b/sigc++/tuple_transform_each.h
index 78da544..9ec9cfb 100644
--- a/sigc++/tuple_transform_each.h
+++ b/sigc++/tuple_transform_each.h
@@ -93,11 +93,11 @@ struct tuple_transform_each_impl {
template <typename T_current, typename T_original>
static decltype(auto)
tuple_transform_each(T_current&& t, T_original& t_original) {
- using element_type = typename std::tuple_element<index, std::decay_t<T_current>>::type;
-
- auto& from = std::get<index>(t_original);
- const auto element = T_transformer<element_type>::transform(from);
- const auto t_element = std::make_tuple(element);
+ using from_element_type = typename std::tuple_element<index, std::decay_t<T_current>>::type;
+ using to_element_type = typename std::result_of<decltype (
+ &T_transformer<from_element_type>::transform)(from_element_type&)>::type;
+ const auto t_element =
+ std::tuple<to_element_type>(T_transformer<from_element_type>::transform(std::get<index>(t_original)));
const auto t_start = tuple_start<index>(std::forward<T_current>(t));
@@ -124,10 +124,12 @@ struct tuple_transform_each_impl<T_transformer, 0> {
tuple_transform_each(T_current&& t, T_original& t_original) {
constexpr std::size_t index = 0;
- using element_type = typename std::tuple_element<index, T_original>::type;
- const auto element =
- T_transformer<element_type>::transform(std::get<index>(t_original));
- const auto tuple_element = std::make_tuple(element);
+ using from_element_type = typename std::tuple_element<index, T_original>::type;
+ using to_element_type = typename std::result_of<decltype (
+ &T_transformer<from_element_type>::transform)(from_element_type&)>::type;
+ const auto tuple_element =
+ std::tuple<to_element_type>(T_transformer<from_element_type>::transform(std::get<index>(t_original)));
+
const auto tuple_rest = tuple_cdr(std::forward<T_current>(t));
return std::tuple_cat(tuple_element, tuple_rest);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]