|
18 | 18 | #ifndef SIGC_TUPLE_UTILS_TUPLE_TRANSFORM_EACH_H
|
19 | 19 | #define SIGC_TUPLE_UTILS_TUPLE_TRANSFORM_EACH_H
|
20 | 20 |
|
21 |
| -// #include <sigc++/tuple-utils/tuple_cat.h> |
22 | 21 | #include <sigc++/tuple-utils/tuple_cdr.h>
|
23 | 22 | #include <sigc++/tuple-utils/tuple_end.h>
|
24 | 23 | #include <sigc++/tuple-utils/tuple_start.h>
|
@@ -47,22 +46,26 @@ struct tuple_transform_each_impl {
|
47 | 46 | using from_element_type = typename std::tuple_element<index, std::decay_t<T_original>>::type;
|
48 | 47 | using to_element_type = typename std::invoke_result<decltype (
|
49 | 48 | &T_transformer<from_element_type>::transform), from_element_type&>::type;
|
50 |
| - const auto t_element = |
| 49 | + // Tuples which are input data to std::tuple_cat() should not be declared const. |
| 50 | + // Some versions of libc++ has a bug in std::tuple_cat(): All output elements |
| 51 | + // coming from a const tuple become const. |
| 52 | + // https://github.com/libsigcplusplus/libsigcplusplus/issues/25 |
| 53 | + auto t_element = |
51 | 54 | std::tuple<to_element_type>(T_transformer<from_element_type>::transform(std::get<index>(t_original)));
|
52 | 55 |
|
53 | 56 | if constexpr(size_from_index == 1) {
|
54 |
| - const auto tuple_rest = tuple_start<size - 1>(std::forward<T_current>(t)); |
| 57 | + auto tuple_rest = tuple_start<size - 1>(std::forward<T_current>(t)); |
55 | 58 | return std::tuple_cat(tuple_rest, t_element);
|
56 | 59 | } else {
|
57 |
| - const auto t_start = tuple_start<index>(std::forward<T_current>(t)); |
| 60 | + auto t_start = tuple_start<index>(std::forward<T_current>(t)); |
58 | 61 |
|
59 | 62 | // t_end's elements will be copies of the elements in t, so this method's
|
60 | 63 | // caller won't see the changes made in the subsequent call of
|
61 | 64 | // tuple_transform_each() on those copies. That's why we pass t_original
|
62 | 65 | // through too, so we can modify that directly.
|
63 | 66 | // the const version (tuple_transform_each_const()) doesn't have to worry
|
64 | 67 | // about this, though avoiding copying would be more efficient.
|
65 |
| - const auto t_end = tuple_end<size - index - 1>(t); |
| 68 | + auto t_end = tuple_end<size - index - 1>(t); |
66 | 69 |
|
67 | 70 | auto t_with_transformed_element = std::tuple_cat(t_start, t_element, t_end);
|
68 | 71 | return tuple_transform_each_impl<T_transformer,
|
|
0 commit comments