【发布时间】:2014-10-10 07:41:31
【问题描述】:
我尝试过使用 clang 的 extended vectors。三元运算符应该可以工作,但它不适合我。示例:
int main()
{
using int4 = int __attribute__((ext_vector_type(4)));
int4 a{0, 1, 3, 4};
int4 b{2, 1, 4, 5};
auto const r(a - b ? a : b);
return 0;
}
请提供我如何使其工作的示例,就像它在 OpenCL 下工作一样。我正在使用clang-3.4.2。
错误:
t.cpp:8:16: error: value of type 'int __attribute__((ext_vector_type(4)))' is not contextually convertible to 'bool'
auto const r(a - b ? a : b);
^~~~~
1 error generated.
【问题讨论】:
-
它对我也不起作用godbolt.org/g/rt67UM
-
我想出了一些解决方法,如果你愿意,我可以把它粘贴在这里。
-
是的,请!回答自己的问题并没有错。即使是部分答案也比非.e好
-
@Zboson 已添加,希望对您有所帮助。
标签: c++ clang ternary-operator simd