Skip to content

Commit 8453a70

Browse files
committed
tuple_transform_each(): Fix for libc++
Tuples which are input data to std::tuple_cat() are not declared const. Some versions of libc++ has a bug in std::tuple_cat(): All output elements coming from a const tuple become const. It can break 'make check' when using clang++ and -stdlib=libc++. Fixes issue #25
1 parent c47ec07 commit 8453a70

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

sigc++/tuple-utils/tuple_transform_each.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#ifndef SIGC_TUPLE_UTILS_TUPLE_TRANSFORM_EACH_H
1919
#define SIGC_TUPLE_UTILS_TUPLE_TRANSFORM_EACH_H
2020

21-
// #include <sigc++/tuple-utils/tuple_cat.h>
2221
#include <sigc++/tuple-utils/tuple_cdr.h>
2322
#include <sigc++/tuple-utils/tuple_end.h>
2423
#include <sigc++/tuple-utils/tuple_start.h>
@@ -47,22 +46,26 @@ struct tuple_transform_each_impl {
4746
using from_element_type = typename std::tuple_element<index, std::decay_t<T_original>>::type;
4847
using to_element_type = typename std::invoke_result<decltype (
4948
&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 =
5154
std::tuple<to_element_type>(T_transformer<from_element_type>::transform(std::get<index>(t_original)));
5255

5356
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));
5558
return std::tuple_cat(tuple_rest, t_element);
5659
} 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));
5861

5962
// t_end's elements will be copies of the elements in t, so this method's
6063
// caller won't see the changes made in the subsequent call of
6164
// tuple_transform_each() on those copies. That's why we pass t_original
6265
// through too, so we can modify that directly.
6366
// the const version (tuple_transform_each_const()) doesn't have to worry
6467
// 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);
6669

6770
auto t_with_transformed_element = std::tuple_cat(t_start, t_element, t_end);
6871
return tuple_transform_each_impl<T_transformer,

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