C++ Logo

std-proposals

Advanced search

Re: [std-proposals] noexcept has gotten a bit hairy -- I want a compiler error

From: Andrey Semashev <andrey.semashev_at_[hidden]>
Date: Sun, 4 May 2025 01:11:17 +0300
On 3 May 2025 21:10, Frederick Virchanza Gotham via Std-Proposals wrote:
> This is a very premature half-baked idea that popped into my head just
> now, but what if we had an operator that could turn an overloaded
> function into a lambda with multiple overloads of operator()? So for
> example consider the two overloads of 'strchr':
>
> const char* strchr( const char* str, int ch );
> char* strchr( char* str, int ch );
>
> What if we could apply the '_Lambda_overloads' operator to 'strchr' as follows:
>
> auto mylambda = _Lambda_overloads( strchr );

  auto mylambda = [](auto&&... args) {
    return strchr(std::forward< decltype(args) >(args)...);
  };

Received on 2025-05-03 22:11:23