C ++ 17 现在已完成功能,因此不太可能进行大的更改。针对 C ++ 17 提出了数百个建议。
其中哪些功能是在 C ++ 17 中添加到 C ++ 的?
使用支持 “C ++ 1z” 的 C ++ 编译器时,当编译器更新为 C ++ 17 时,哪些功能将可用?
[*this]{ std::cout << could << " be " << useful << '\n'; }
using
in 属性可以避免重复属性名称空间。
现在, 要求编译器忽略他们无法识别的非标准属性 。
简单的static_assert(expression);
没有字符串
std::tie
与auto
const auto [it, inserted] = map.insert( {"foo", bar} );
it
并inserted
从与推定的类型pair
那个map::insert
回报。 std::array
和相对平坦的结构 if (init; condition)
并switch (init; condition)
if (const auto [it, inserted] = map.insert( {"foo", bar} ); inserted)
if(decl)
扩展到decl
不能明智地转换为布尔的情况。 固定(某些)表达式的求值顺序并进行一些修改
.then
继续工作。 前向进度保证(FPG)( 以及用于并行算法的 FPG)
u8'U', u8'T', u8'F', u8'8'
字符文字(字符串已存在)
std::string
类似于引用字符数组或子字符串string const&
。也可以使解析速度加快一倍。 "hello world"sv
char_traits
std::byte
超出了他们的承受能力。
std::invoke
std::apply
std::make_from_tuple
, std::apply
应用于对象构造
is_invocable
, is_invocable_r
, invoke_result
result_of
is_invocable<Foo(Args...), R>
是 “可以用Args...
调用Foo
Args...
并获得与R
兼容的东西”,其中R=void
是默认值。 invoke_result<Foo, Args...>
是std::result_of_t<Foo(Args...)>
但显然不太混乱? [class.directory_iterator]
和[class.recursive_directory_iterator]
[class.directory_iterator]
[class.recursive_directory_iterator]
for_each_n
reduce
transform_reduce
exclusive_scan
inclusive_scan
transform_exclusive_scan
transform_inclusive_scan
为线程目的而添加,即使不使用线程也可以暴露
atomic<T>
::is_always_lockfree
std::lock
时,可以节省一些std::lock
痛苦。 std
算法和相关机制[func.searchers]
和[alg.search]
std::function
的分配器 std::sample
,从某个范围采样?
拼接map<>
, unordered_map<>
, set<>
和unordered_set<>
字符串的非 const .data()
。
非成员std::size
, std::empty
, std::data
std::begin
/ end
现在, emplace
函数家族返回对创建对象的引用 。
unique_ptr<T[]>
修复和其他unique_ptr
调整。 weak_from_this
和一些固定为此共享std
数据类型改进: C ++ 17 库基于C11 而不是 C99
为将来的标准库保留std[0-9]+
std
实现中已经公开的实用程序代码std::clamp()
std::clamp( a, b, c ) == std::max( b, std::min( a, c ) )
大致gcd
和lcm
std::uncaught_exceptions
std::as_const
std::bool_constant
_v
模板变量 std::void_t<T>
std::owner_less<void>
std::less<void>
,但用于基于内容进行排序的智能指针std::chrono
波兰语 std::conjunction
, std::disjunction
, std::negation
暴露std::not_fn
std
内 noexcept 的规则 std::less
间接访问。<codecvt>
memory_order_consume
result_of
,替换为invoke_result
shared_ptr::unique
,它不是很线程安全的从 C ++ 14 开始, Isocpp.org 具有独立的更改列表。它已被部分掠夺。
自然,TS 工作会并行继续进行,因此,有些尚未成熟的 TS 必须等待下一次迭代。下一次迭代的目标是先前计划的 C ++ 20,而不是某些谣言所暗示的 C ++ 19。避免使用 C ++ 1O。
来自此 reddit 帖子和此 reddit 帖子的初始列表,以及通过谷歌搜索或从上面的 isocpp.org 页面添加的链接。
从SD-6功能测试列表中掠夺的其他条目。
接下来将掠夺clang 的功能列表和库功能列表 。这似乎并不可靠,因为它是 C ++ 1z,而不是 C ++ 17。
这些幻灯片具有某些其他地方缺少的功能。
虽然没有询问 “删除了什么”,但这是一些简短的列表,其中列出了从 C ++ 中从 C ++ 17 中删除的一些东西((大多数是?)先前已弃用的东西):
register
,保留关键字以备将来使用bool b; ++b;
<functional>
内容, random_shuffle
std::function
分配器 有改写。我不确定这些对代码是否有影响,或者它们是否只是标准中的清理内容:
P0505R0 (constexpr 计时)
P0418R2 (原子调整)
P0512R0 (模板参数扣除调整)
P0490R0 (结构化绑定调整)
P0513R0 (更改为std::hash
)
P0502R0 (并行例外)
P0509R1 (更新异常处理限制)
P0012R1 (使异常规格成为类型系统的一部分)
P0510R0 (型号限制)
P0504R0 (可选 / 变体 / 任何标签)
P0497R0 (共享的 PTR 调整)
P0508R0 (结构化绑定节点句柄)
P0521R0 (共享指针使用计数和唯一更改?)
https://isocpp.org/files/papers/p0636r0.html