C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::constant_size_function

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Mon, 17 Jun 2024 00:11:21 +0100
On Sun, Jun 16, 2024 at 11:59 PM Frederick Virchanza Gotham wrote:
>
> I'm probably way off here, but here's what I was thinking:
>
> https://godbolt.org/z/3bK7zdT1a
>
> Note however that the static_assert on Line #17 fails.


A workaround is to multiply the number of captures by the size of a
pointer -- and that's the size of the lambda (assuming that every
capture is capture-by-reference).

So the explicit deduction guide changes to:

      template<typename F, typename... Params>
      elide(F &&arg,Params&&... args)
      ->
      elide< invoke_result_t<F&&,Params&&...>,
sizeof(void*)*(1u+sizeof...(args)) >;

Tested and working:

    https://godbolt.org/z/9eo7MGc8c

Still though. . . . I have a feeling that you guys had in mind
something much more simple. I still don't know what.

Received on 2024-06-16 23:11:31