C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::elide

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Thu, 30 May 2024 08:39:05 +0100
On Wed, May 29, 2024 at 11:58 PM Gašper Ažman wrote:
>
> I'm still missing a call operator on the class to force the conversion.
>
> That one is crucial for interop with other eliders.


Not sure what you mean by "interop with other eliders". If you mean
classes derived from std::elide, well you can do this:

    template<typename T>
    class elide {
    public:
        operator T(void)
        {
            return {};
        }
    };

    template<typename T>
    class MyElider : public elide<T> {
    public:
        operator T(void)
        {
            return this->elide<T>::operator T();
        }
    };

And if you mean classes that contain, or interact with, another
elider, then you can do:

    template<typename T>
    class MyElider {
        elide<T> e;
    public:
        operator T(void)
        {
            return e.operator T();
        }
    };

Please write a code snippet to show me what you mean.

Received on 2024-05-30 07:39:21