主要观点:本文讨论了 C++26 中被移除或即将被移除的语言和库特征,包括std::allocator
的typedef
、std::basic_string::reserve()
的函数重载、<codecvt>
头、std::strtok
、strstreams
、std::wstring_convert
、std::is_trivial
和std::memory_order::consume
等,并介绍了相关的提案和原因,强调了 deprecation 并非单向道路,下周将讨论 C++26 中被 underprecated 的特征。
关键信息:
- C++20 已弃用
std::allocator
的typedef
,C++26 最终移除。 std::basic_string::reserve()
无参数重载在 C++20 被弃用,C++26 移除。<codecvt>
头因规格不足在 C++26 被移除。std::strtok
在 C++26 因 C 标准更新而被移除。- C++20 引入高效移动字符串的功能,C++26 移除
char*
流。 - C++20 引入的
std::atomic<shared_ptr<T>>
替代了旧的shared_ptr
原子访问 API。 std::wstring_convert
等在 C++26 被移除。std::is_trivial
及其相关功能被弃用。std::memory_order::consume
因规格问题被弃用。
重要细节:- 类继承
std::allocator
时需添加typedef
以确保正确行为。 reserve
默认值为 0 时可替代shrink_to_fit
,但后者在 C++11 引入后前者行为多余。<codecvt>
头易受攻击,移除是为提高语言安全性。std::strtok
是 C 函数,C++不再需要。char*
流近 30 年前就被标记为未来弃用。is_trivial
未检查构造函数的 public 属性。std::memory_order::consume
规格不佳,大多被映射为std::memory_order::acquire
。
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。