C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::elide

From: Gašper Ažman <gasper.azman_at_[hidden]>
Date: Thu, 30 May 2024 13:26:07 +0100
I meant the following:

I have two eliders, one mine, and one now being std::elide.

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.


struct myclass {
    template <typename F>
    myclass(my_elider<F> e);
};

std::vector<myclass> v;
v.emplace_back(std::elide{...}); // this should just work if std::elide
also models callable

If my class has a constructor from std::elide, then my_elider<F> will also
just work because my_elider<F> is also callable, so elide just thinks its a
function.

Nesting these arbitrarily is important because so many libraries have their
own internal eliders. having special cases for calling "operator T()" is
undesirable.



On Thu, May 30, 2024, 08:39 Frederick Virchanza Gotham via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> 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.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2024-05-30 12:26:20