c++ - 歧义语句 C++-AMP : (extent) is ambiguous

标签 c++ visual-c++ c++-amp

我正在尝试用 C++-AMP 编写代码,将多个 2D vector 复制到 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;

最佳答案

该消息意味着编译器无法判断您是需要 std::extent 还是 concurrency::extent。可以通过三种方法解决此问题:

  • 删除引入 std::extent#include - 这不太可能是一个好的解决方案,因为您可能需要该 header 中的内容
  • 每次使用时都通过全名调用 concurrency::extent - 笨拙,但会起作用
  • 删除 using namespace std; 并将其替换为单独的语句,例如 using std::endl;,如您在 #include 语句中所见.

我最喜欢最后一个,尽管它更费功夫。发现您需要其中哪一个的最佳方法是删除 using namespace std; 并编译。错误消息会让您知道您正在使用 std 中的哪些类型。

关于c++ - 歧义语句 C++-AMP : (extent) is ambiguous,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17169332/

相关文章:

c++ - 为什么在这个例子中模板参数的顺序对 MS C++ 编译器很重要?

c++ - 限制(amp)函数类型

language-agnostic - 并发和内存模型

c++ - 检查是否存在 Windows API 函数

C++ 如何获得指向 lambda 函数的空指针?

c++ - C/C++ : How to use the do-while(0); construct without compiler warnings like C4127?

c++-amp - C++ amp矩阵乘法accelerator_view_removed在内存位置

c++ - 将 CreateDIBSection BMP 数据写入文件

c++ - 使用带有 MFC CString 的 boost 字符串算法来检查字符串的结尾

c++ - 如何获取12 :00PM of the day的SYSTEM时间