C++26 introduces std::indirect and std::polymorphic as new vocabulary types in <memory> (P3019R14) that provide value-like semantics for dynamically-allocated objects while preserving const correctness. These types solve the fundamental issue where unique_ptr breaks const propagation by returning non-const references through const access paths.
Background
C++26标准委员会持续推进内存管理和智能指针的改进工作,P3019R14合并了之前独立的P1950和P0201两个提案,旨在解决unique_ptr在值类型类中const传播的关键缺陷。
- Source
- Lobsters
- Published
- Aug 12, 2026 at 02:45 PM
- Score
- 8.0 / 10