【发布时间】:2016-05-01 20:47:44
【问题描述】:
我知道std::is_pod。但它检查的不仅仅是聚合类型。或者,std::is_pod 只是我们能做的最好的吗?
基本上,我想为this写一个函数模板:
template <typename T>
aggregate_wrapper<T> wrap(T&& x);
仅当T 为聚合类型时才启用。
【问题讨论】:
-
我想不出
is_aggregate的任何实际应用。例如。它对序列化没有帮助。 -
如果您正在寻找可以告诉您何时的类型特征,例如
memcpy是安全的,那么你想要std::is_trivially_copyable。 -
@Cheersandhth.-Alf 我想为this写一个
wrap()函数模板,只有当T是一个聚合类型时才启用。 -
std::is_object或std::is_compound不能满足您的需求吗? -
@mindriot 不。这是关于初始化语法的。聚合类型支持
{},但不支持()。
标签: c++ language-lawyer c++14 template-meta-programming typetraits