# C++26의 std::polymorphic, clone() 없이 다형성과 값 의미론을 동시에 잡다

Original title: Composite objects and C++26 the std:polymorphic type

> Hacker News story 50148845 · language: ko · submitted 2026-10-19
> Web version: https://zeli.app/ko/story/50148845
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 46 · by [jandeboevrie](<https://news.ycombinator.com/user?id=jandeboevrie>) · 💬 33
[original](<https://mariusbancila.ro/blog/2026/10/18/composite-objects-and-cpp26-the-stdpolymorphic-type/>) · [HN discussion](<https://news.ycombinator.com/item?id=50148845>)

## Summary

C++26에 추가된 std::polymorphic는 런타임에 동적 타입이 바뀌는 멤버를 값처럼 소유할 수 있게 해준다. 기존에는 unique_ptr와 가상 clone() 함수로 복사를 흉내 내야 했고, 이는 Rule of Five 위반, const 전파 실패, null 가능성 같은 문제를 낳았다. std::polymorphic는 생성 시점에 복사 연산을 타입 소거해 저장하므로 clone() 프로토콜 없이도 깊은 복사, 깊은 const, 절대 null이 아닌 불변식을 타입 시스템으로 보장한다. 이벤트 로그 예제를 통해 코드가 얼마나 단순해지는지 보여준다.

## Key quote

> std::polymorphic는 생성 시점에 구체 타입을 정적으로 알기 때문에 복사 연산을 타입 소거해 저장한다. 나중에 복사 생성자는 저장된 연산을 호출할 뿐이며, 이는 std::function과 std::any가 쓰는 기법을 복사 생성자에 적용한 것이다.

---

## Cite

- Page: https://zeli.app/ko/story/50148845
- Date: 2026-10-19
- Source: mariusbancila.ro (https://mariusbancila.ro/blog/2026/10/18/composite-objects-and-cpp26-the-stdpolymorphic-type/)
- Hacker News: https://news.ycombinator.com/item?id=50148845

## Other languages

- en: https://zeli.app/story/50148845 · markdown: https://zeli.app/story/50148845.md
- zh: https://zeli.app/zh/story/50148845 · markdown: https://zeli.app/zh/story/50148845.md
- ja: https://zeli.app/ja/story/50148845 · markdown: https://zeli.app/ja/story/50148845.md
- de: https://zeli.app/de/story/50148845 · markdown: https://zeli.app/de/story/50148845.md
- es: https://zeli.app/es/story/50148845 · markdown: https://zeli.app/es/story/50148845.md
- ru: https://zeli.app/ru/story/50148845 · markdown: https://zeli.app/ru/story/50148845.md
