[Bug c++/82619] C++17 std::apply treated as in global namespace under certain circumstances
tower120 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Oct 19 17:29:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82619
tower120 <tower120 at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution|--- |INVALID
--- Comment #4 from tower120 <tower120 at gmail dot com> ---
Sorry, this is ADL indeed.
I just noticed, that I tested in other compilers with -std=C++14 flag. That's
why that worked in all other compilers and pre gcc7.
Now, being aware of ADL, I am able to make the shortest version of "bug":
#include <tuple>
namespace ns {
template<class F, class Tuple, std::size_t... I>
static constexpr decltype(auto) apply_impl(F &&f, Tuple &&t,
std::index_sequence<I...>) {
return f(std::get<I>(std::forward<Tuple>(t))...);
}
template<class F, class Tuple>
static constexpr decltype(auto) apply(F &&f, Tuple &&t) {
return apply_impl(std::forward<F>(f), std::forward<Tuple>(t),
std::make_index_sequence<std::tuple_size<std::decay_t<Tuple>>::value>{});
}
template<class Closure, class Tuple>
static void foreach_tuple(Closure &&closure, Tuple &&tuple) {
//ns::
apply([&](auto &&... args) {}, tuple);
}
}
int main() {
std::tuple t = {1,2,3};
ns::foreach_tuple([](auto i){}, t);
return 0;
}
More information about the Gcc-bugs
mailing list