Permisuan
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
lysdexic@programming.devM to C++@programming.devEnglish · 12 days ago

C++26: std::polymorphic

www.sandordargo.com

external-link
message-square
0
fedilink
1
external-link

C++26: std::polymorphic

www.sandordargo.com

lysdexic@programming.devM to C++@programming.devEnglish · 12 days ago
message-square
0
fedilink
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 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, 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.
alert-triangle
You must log in or register to comment.

C++@programming.dev

cpp@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !cpp@programming.dev

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++.
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 12 users / day
  • 0 users / week
  • 0 users / month
  • 0 users / 6 months
  • 1 local subscriber
  • 2.35K subscribers
  • 50 Posts
  • 0 Comments
  • Modlog
  • mods:
  • lysdexic@programming.dev
  • Nihili0@programming.dev
  • UI: 0.19.5
  • BE: 0.19.19
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org