Date: Wed, 30 Apr 2025 21:32:20 +0300
On Wed, 30 Apr 2025 at 20:59, Hans Ã…berg <haberg_1_at_[hidden]> wrote:
> > And it has the advantage over a polymorphic
> > cloning function that a polymorphic cloning function needs
> > to decide how the object is allocated, whereas for use with
> > std::polymorphic, all your type needs to be is to be copyable,
> > and various different allocation strategies can be employed. That
> > makes the combination more flexible, while requiring
> > much less from your type A. You get polymorphic copies and the base
> > interface, and all you need to opt in to that is to
> > make your type copyable.
>
> I have only had the need for different allocation strategies with GC references: different forms of reference counting, and Boehm GC.
Right, but if you ever need it, you can just use it without any extra
work on your type A. Maybe you'll need it one day, maybe someone
who (re)uses your code will need it, maybe either of those audiences
needs to slot in a debug allocator at one point. The advantage
is already there, and you don't need to do anything in your type A to
benefit from it.
> > And it has the advantage over a polymorphic
> > cloning function that a polymorphic cloning function needs
> > to decide how the object is allocated, whereas for use with
> > std::polymorphic, all your type needs to be is to be copyable,
> > and various different allocation strategies can be employed. That
> > makes the combination more flexible, while requiring
> > much less from your type A. You get polymorphic copies and the base
> > interface, and all you need to opt in to that is to
> > make your type copyable.
>
> I have only had the need for different allocation strategies with GC references: different forms of reference counting, and Boehm GC.
Right, but if you ever need it, you can just use it without any extra
work on your type A. Maybe you'll need it one day, maybe someone
who (re)uses your code will need it, maybe either of those audiences
needs to slot in a debug allocator at one point. The advantage
is already there, and you don't need to do anything in your type A to
benefit from it.
Received on 2025-04-30 18:32:36