kev*_*man 5 c++ visual-c++ c++11 c++-amp visual-studio-2012
以下代码无法编译.错误消息是:
错误1:
error C3930: 'foo' : no overloaded function has restriction specifiers that are compatible with the ambient context ''
Run Code Online (Sandbox Code Playgroud)
错误2:
error C2660: 'f1' : function does not take 0 arguments
Run Code Online (Sandbox Code Playgroud)
错误3:
IntelliSense: amp-restricted function "int foo() restrict(amp)" (declared at line 5) must be called from an amp-restricted function
Run Code Online (Sandbox Code Playgroud)
该程序:
#include <amp.h>
#include <iostream>
using namespace std;
int foo() restrict(amp) { return 5; }
int f1(int x = foo()) restrict(amp) {
return x;
}
int main()
{
using namespace concurrency;
int a[10] = {0};
array_view<int> av(10, a);
parallel_for_each(av.extent, [=](index<1> i) restrict(amp) {
av[i] = f1();
});
for(unsigned i=0; i<10; ++i) {
cout << av[i] << "\n";
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
奇怪的是,当我删除restrict(amp)on foo(),并用f1()lambda 替换lambda中的调用时5,程序编译得很好.那么在放大器函数的默认参数中,函数调用的规则是什么?
| 归档时间: |
|
| 查看次数: |
1407 次 |
| 最近记录: |