【发布时间】:2021-12-26 04:39:23
【问题描述】:
目标是编写具有以下签名的类型特征:
template<typename T>
struct is_vector : std::true_type / std::false_type
这样您就可以在 SFINAE 签名中使用is_vector<T>::value。如何正确检测 GCC/clang 中的类型是否为 __attribute__((__vector_size(<some_vector_width>)) <some_built-in_type>?
我查看了the LLVM documentation,但没有看到任何内置插件可以检测到这一点。 GNU C documentation 同样仅将其记录为 C 扩展,并未提及 C++。
备份计划是为每个排列专门化模板,但这听起来确实不太好。
【问题讨论】:
-
您可以编写部分专业化。不过,这方面可能存在已知的 gcc 错误。
-
将所有此类类型包装在一个已知的模板类中,然后匹配它可能会更容易。