模糊语句C++ - AMP :(范围)含糊不清

Haw*_*awk 3 c++ visual-c++ c++-amp

我正在尝试用C++编写代码 - AMP将多个2D矢量复制到GPU内存中进行处理.但是,一旦我从表达式开始,extent<2> eM(100,100);我面临这个错误:"范围"是模棱两可的.与C++中的任何其他扩展表达式是否存在冲突?是因为我使用的库?这些都是我所包含的库和命名空间,我不能包含它很长的代码并且会让人感到困惑.

#include "stdafx.h"
#include <Windows.h>
#include <stdint.h>
#include <amp.h>
#include <Shlwapi.h>
#include <vector>
#include <random>
#include <iostream>
using std::endl;
using std::cout;
#include <iomanip>
#include "timer.h"
#include <fstream>
using std::ifstream;
#include <cstring>
#include <sstream>
#include <tchar.h>
using namespace std;
using namespace concurrency;
using std::vector;
Run Code Online (Sandbox Code Playgroud)

Kat*_*ory 5

该消息意味着编译器无法判断您是否需要std::extentconcurrency::extent.有三种方法可以解决这个问题:

  • 删除#include引入的内容std::extent- 这不太可能是一个很好的解决方案,因为你可能需要来自该标题的内容
  • concurrency::extent无论何时使用它,都要用它的全名调用- 笨拙,但会起作用
  • 删除using namespace std;并替换using std::endl;为您在#include语句中看到的单个语句.

我喜欢最后一个最好的,虽然这是更多的工作.发现您需要的最佳方法是删除using namespace std;和编译.错误消息将告诉您正在使用的std中的哪些类型.

  • 使用std和concurrency命名空间时还有其他类似的冲突; 我想到了数组,范围和索引. (2认同)