C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::elide

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Thu, 30 May 2024 16:14:14 +0100
On Thu, May 30, 2024 at 1:26 PM Gašper Ažman wrote:
>
> Both call a function to generate the returned type. Why
> can't an elider *be that function* directly? That way I can
> nest them either way and it still works.


Let's see if I understand. In the following godbolt which
torture-tests 'std::elide':

      https://godbolt.org/z/bv959jvM3

I have made the following two additions:

Line #27:

      template<typename NestedF, typename... NestedParams>
      constexpr decltype(auto) operator()(NestedF &&fN, NestedParams&&... argsN)
      {
          return forward<NestedF>(fN)( forward<NestedParams>(argsN)... );
      }

Line #183:

    struct MyElider {
        template<typename... Ts> MyElider(Ts&&...) {}

        operator counting_semaphore<8>(void)
        {
            return counting_semaphore<8>{5};
        }

        counting_semaphore<8> operator()(void)
        {
            return counting_semaphore<8>{6};
        }
    };

    void Chain(void)
    {
        std::optional< counting_semaphore<8> > ocs8;
        ocs8.emplace( std::elide( MyElider(
std::elide(ReturnByValueWithArg,7) ) ) );
        ocs8.emplace( MyElider( std::elide(
MyElider(ReturnByValueWithArg,7) ) ) );
    }

Is that what you were going for? By the way, one other thing: On the
committee call on Tuesday, somebody mentioned something about 'move
semantics' but didn't go into any further detail. I don't think the
godbolt contains any bug to do with move semantics.

Received on 2024-05-30 15:14:28