[Bug c++/85743] New: Cannot call template member function inside a variadic lambda unless specifying `this`
gufideg at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri May 11 03:31:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85743
Bug ID: 85743
Summary: Cannot call template member function inside a variadic
lambda unless specifying `this`
Product: gcc
Version: 8.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: gufideg at gmail dot com
Target Milestone: ---
When using a particular pattern to expand a variadic template inside a member
function, `this->` need to be specified before calling other member functions.
Here is the most reduced repro I can come with at the moment:
#include <type_traits>
#include <tuple>
template<typename>
struct tuple_sequence;
template<typename I, I... S>
struct tuple_sequence<std::integer_sequence<I, S...>> {
using type = std::tuple<std::integral_constant<I, S>...>;
};
template<typename... Types, typename F>
constexpr auto apply_sequence_for(F function) -> decltype(auto) {
return std::apply(function, typename
tuple_sequence<std::index_sequence_for<Types...>>::type{});
}
template<typename... Ts>
struct Foo {
template<typename T, typename...>
constexpr void boom(int i) const {}
constexpr auto foo(std::array<int, sizeof...(Ts)> data) const {
apply_sequence_for<Ts...>([this, &data](auto... s) {
(boom<Ts>(data[s]), ...);
});
}
};
int main() {
Foo<int, float, char> f;
f.foo({0, 1, 2});
}
Notice the particular expansion pattern `boom<Ts>(data[s])`. The bug won't
trigger if the pattern is replaced by `boom<Ts...>(data[s])` or even
`boom<Ts>(data[0])`.
This code compiles under Clang 6.0.0
Live example: https://godbolt.org/g/n6wMUS
More information about the Gcc-bugs
mailing list