gpt4 book ai didi

c++ - 为什么在 C++20 中不推荐使用 std::is_pod?

转载 作者:IT老高 更新时间:2023-10-28 13:20:38 42 4
gpt4 key购买 nike

std::is_pod 在 C++20 中可能会被弃用。
这个选择的原因是什么?我应该用什么来代替 std::is_pod 来知道一个类型是否真的是一个 POD?

最佳答案

POD 正在被两个类别所取代,这些类别提供更多细微差别。 c++ standard meeting in november 2017不得不说:

Deprecating the notion of “plain old data” (POD). It has been replaced with two more nuanced categories of types, “trivial” and “standard-layout”. “POD” is equivalent to “trivial and standard layout”, but for many code patterns, a narrower restriction to just “trivial” or just “standard layout” is appropriate; to encourage such precision, the notion of “POD” was therefore deprecated. The library trait is_pod has also been deprecated correspondingly.

对于简单的数据类型,使用 is_standard_layout函数,对于琐碎的数据类型(例如简单结构),使用 is_trivial功能。

关于c++ - 为什么在 C++20 中不推荐使用 std::is_pod?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48225673/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com