On Thu, 27 Nov 2025 at 13:51, Jonathan Wakely <[email protected]> wrote:
>
> On Thu, 27 Nov 2025 at 13:43, Tomasz Kamiński <[email protected]> wrote:
> >
> > The lambda is considered to be TU-local entity, use a named function
> > instead.
> >
> > libstdc++-v3/ChangeLog:
> >
> > * include/std/ranges (__func_handle::__select): Named function
> > extracted from local lambda.
> > (__detail::__func_handle_t): Define using __func_handle::__select.
> > ---
> > Tested on x86_64-linux. OK for trunk?
> ]
> OK
As discussed over chat, the new __select() function could be
'consteval' instead of 'constexpr'. OK with or without that change.
> >
> > libstdc++-v3/include/std/ranges | 33 +++++++++++++++++++--------------
> > 1 file changed, 19 insertions(+), 14 deletions(-)
> >
> > diff --git a/libstdc++-v3/include/std/ranges
> > b/libstdc++-v3/include/std/ranges
> > index 7c5ac931e31..a756f1ef3db 100644
> > --- a/libstdc++-v3/include/std/ranges
> > +++ b/libstdc++-v3/include/std/ranges
> > @@ -448,23 +448,28 @@ namespace ranges
> >
> > noexcept(noexcept(_Fn::operator()(__iters[iter_difference_t<_Iters>(__n)]...)))
> > { return
> > _Fn::operator()(__iters[iter_difference_t<_Iters>(__n)]...); }
> > };
> > +
> > + template<typename _Fn, typename... _Iters>
> > + constexpr auto
> > + __select()
> > + {
> > + using _Fd = remove_cv_t<_Fn>;
> > + if constexpr (is_member_pointer_v<_Fd>)
> > + return __func_handle::_InplaceMemPtr<_Fd>();
> > + else if constexpr (is_function_v<remove_pointer_t<_Fd>>)
> > + return __func_handle::_Inplace<_Fd>();
> > + else if constexpr (__is_std_op_wrapper<_Fd>)
> > + return __func_handle::_Inplace<_Fd>();
> > + else if constexpr (requires (const _Iters&... __iters)
> > + { _Fd::operator()(*__iters...); })
> > + return __func_handle::_StaticCall<_Fd>();
> > + else
> > + return __func_handle::_ViaPointer<_Fn>();
> > + };
> > } // __func_handle
> >
> > template<typename _Fn, typename... _Iters>
> > - using __func_handle_t = decltype([] {
> > - using _Fd = remove_cv_t<_Fn>;
> > - if constexpr (is_member_pointer_v<_Fd>)
> > - return __func_handle::_InplaceMemPtr<_Fd>();
> > - else if constexpr (is_function_v<remove_pointer_t<_Fd>>)
> > - return __func_handle::_Inplace<_Fd>();
> > - else if constexpr (__is_std_op_wrapper<_Fd>)
> > - return __func_handle::_Inplace<_Fd>();
> > - else if constexpr (requires (const _Iters&... __iters)
> > - { _Fd::operator()(*__iters...); })
> > - return __func_handle::_StaticCall<_Fd>();
> > - else
> > - return __func_handle::_ViaPointer<_Fn>();
> > - }());
> > + using __func_handle_t = decltype(__func_handle::__select<_Fn,
> > _Iters...>());
> > } // namespace __detail
> >
> > /// A view that contains exactly one element.
> > --
> > 2.51.1
> >