// P2036R3 - Change scope of lambda trailing-return-type // PR c++/102610 // { dg-do compile { target c++17 } } struct integral_constant { using type = integral_constant; }; template using __bool_constant = integral_constant; template struct is_invocable : __bool_constant {}; int forward() { return 42; } template class tuple; struct plus { template constexpr auto operator()(_Tp __t, _Up __u) { return __t > __u; } }; constexpr auto equal() { int t = 0; return [t = 3](auto obj) -> decltype(obj == t) { return t; }; } template struct is_tuple_invocable; template struct is_tuple_invocable> { using type = typename is_invocable::type; }; namespace detail { template constexpr auto compose(__bool_constant, F f, Tail tail, T... objs) { return f(tail(objs...)); } } // namespace detail template constexpr auto compose(F f, Fs... fs) { return [f, tail(fs...)](auto... objs) { auto unitail = typename is_tuple_invocable>::type{}; return detail::compose(unitail, f, tail, objs...); }; } template constexpr auto eq = equal(); static_assert(compose(eq<3>, plus{})(1, 2));