GoThread
appearance log in
home all local communities
c/cpp@programming.dev

C++

log in to join
follow from another instance

Not on this instance? Enter your own instance's domain to go straight to following c/cpp@programming.dev there.

hashtags

#cpp
0
c/cpp@programming.dev · lysdexic@programming.dev · 19 Aug 2026 11:43

C++26: std::polymorphic

#cpp
Sandor Dargo’s Blog C++26: std::polymorphic In the previous article, we looked at std::indirect — C++26’s answer to the “I need a heap-allocated member with value semantics” problem. indirect<T> always stores exactly a T. But what if you need to store a Circle or a Rectangle through a Shape base class — and copy it without slicing? That’s std::polymorphic<T>, the other half of P3019R14. It owns a heap-allocated object whose dynamic type may be T or any type derived from T. Copying performs a type-erased deep copy that preserves the dynamic type. No virtual clone() needed. www.sandordargo.com

check post at origin

0 comments

0 comments

log in to comment.

about

The center for all discussion and news regarding C++.

Rules

  • Respect instance rules.
  • Don’t be a jerk.
  • Please keep all posts related to C++.
members
2404
posts
50
created
13 Jun 2023
active / week
1
active / month
3

moderators

  • @lysdexic@programming.dev
  • @Nihili0@programming.dev

rss · modlog

GoThread · self-hosted threadiverse · instances · modlog · rss · appearance · AGPL-3.0