C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Extend std::type_info with more information

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Mon, 15 Apr 2024 09:48:26 -0400
On Mon, Apr 15, 2024 at 4:05 AM Ville Voutilainen via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> On Fri, 12 Apr 2024 at 18:16, Thiago Macieira via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> > Still, we are talking about storing a polymorphic type inside of std::any and
> > the general rule of thumb is that an object is EITHER polymorphic or copyable,
>
> That's going to change once std::polymorphic is realized to be
> available by a wide audience.

For places where what the OP is trying to do makes any kind of sense,
I feel like storing a polymorphic<B> inside the any is the right way
to go. The receiving code knows to expect a polymorphic value of a
particular base class, and the sending code is obligated to use that
kind of object.

> > not both. Storing an uncopyable object inside of std::any sounds just wrong. I
>
> You can't even do that, std::any requires that the stored object is
> CopyConstructible. And of course
> it does - std::any is copyable, and it erases the element type, so
> quite like std::function and std::copyable_function,
> it must require that the element is copyable.
>
> > don't think it supports storing immovable types at all, does it? So this alone
>
> No, because those aren't CopyConstructible.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2024-04-15 13:48:39