为什么在C ++ 20中不推荐使用std :: is_pod? [英] Why is std::is_pod deprecated in C++20?

查看:145
本文介绍了为什么在C ++ 20中不推荐使用std :: is_pod?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

std :: is_pod 在C ++ 20中可能已被弃用。

选择该选项的原因是什么?我应该使用什么代替 std :: is_pod 来知道某个类型是否实际上是POD?

解决方案

POD被替换为两个类别,这些类别提供了更多细微差别。 c ++标准会议在2017年11月对此有这样的说法:


不再使用普通旧数据(POD)的概念。它已被两个更细微的类别所取代,即平凡的和标准布局。 POD等效于简单且标准的布局,但是对于许多代码模式而言,仅将琐碎或标准布局的限制更窄些是合适的;为了鼓励这种精确度,因此不赞成使用 POD的概念。库特征is_pod也已被相应弃用。


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

std::is_pod will be probably deprecated in C++20.
What's the reason for this choice? What should I use in place of std::is_pod to know if a type is actually a POD?

解决方案

POD is being replaced with two categories that give more nuances. The c++ standard meeting in november 2017 had this to say about it:

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.

For simple data types use the is_standard_layout function, for trivial data types (such as simple structs) use the is_trivial function.

这篇关于为什么在C ++ 20中不推荐使用std :: is_pod?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆