Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/133.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ “类没有成员”;第二个“U参数”类型;将std::ref()与nvcc一起使用时_C++_Cuda_Nvcc - Fatal编程技术网

C++ “类没有成员”;第二个“U参数”类型;将std::ref()与nvcc一起使用时

C++ “类没有成员”;第二个“U参数”类型;将std::ref()与nvcc一起使用时,c++,cuda,nvcc,C++,Cuda,Nvcc,我正试图使用cuda 7.5.18和gcc 5.4.0编译一个带有nvcc的c++文件,但遇到了错误。以下面的简单示例为例: #include <thrust/functional.h> struct test_struct { //.. } void f(test_struct& a) { //.. } int main() { test_struct a; std::function<void()> bound_f = s

我正试图使用cuda 7.5.18和gcc 5.4.0编译一个带有
nvcc
c++
文件,但遇到了错误。以下面的简单示例为例:

#include <thrust/functional.h>

struct test_struct {
    //..
}

void f(test_struct& a) {
    //..
}

int main() {
    test_struct a;
    std::function<void()> bound_f = std::bind(f, std::ref(a));
}
我找不到任何与以下行相关的nvcc
错误:。。。没有成员“second\u argument\u type”
等等,所以我完全不知道。显然,
std::function
的类成员不知怎么找不到(请参阅)


如何解决此问题?

错误原因尚不清楚,但您可以轻松解决lambda问题:

std::function<void()> bound_f = [&a](){ return f(a); };
std::函数绑定_f=[&a](){返回f(a);};

不幸的是,当我试图编译一个无法轻松更改的大型项目时,出现了上述错误。您的代码没有多大意义。如果你使用C++代码库中的<代码>函数> />代码和朋友,为什么没有<代码>包含< /代码>任何地方?为什么要导入
推力::功能性
?这两者是不能互换的。。。。包括通过。此外,这只是一个MWE,我不认为代码有意义。我只是在基于cuda编译一个更大的项目时遇到了这些错误。无论我对您的代码做了什么(明显的错误丢失),我都无法使用g++4.8和cuda 7.5发行版工具包再现任何类型的编译错误。这看起来像是CUDA不支持gcc 5的一个简单例子。升级到CUDA 8 RC候选版本或降级到受支持的编译器HI,这可能是原因,因为CUDA需要gcc-4.x。我试试看。非常感谢。结果表明,编译可以使用gcc-4.9。如果你能把你的评论表述成一个答案,我会接受的。
std::function<void()> bound_f = [&a](){ return f(a); };