Is there a compile-time func/macro to determine if a C++0x struct is POD?

倖福魔咒の 提交于 2019-11-30 08:05:34

C++0x introduces a type traits library in the header <type_traits> for this sort of introspection, and there is an is_pod type trait. I believe that you would use it in conjunction with static_assert as follows:

static_assert(std::is_pod<A>::value, "A must be a POD type.");

I'm using ISO draft N3092 for this, so there's a chance that this is out of date. I'll go look this up in the most recent draft to confirm it.

EDIT: According to the most recent draft (N3242) this is still valid. Looks like this is the way to do it!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!