mercredi 25 novembre 2015

std::function parameter is incomplete type not allowed

I am trying to assign a lambda to an std::function, like so:

std::function<void>(thrust::device_vector<float>&) f;
f = [](thrust::device_vector<float> & veh)->void
{   
    thrust::transform( veh.begin(), veh.end(), veh.begin(), tanh_f() );
};

And I get an error:

 error: incomplete type is not allowed
 error: type name is not allowed

I think it refers to thrust::device_vector<float>. I tried typenaming and typedefining the parameter:

typedef typename thrust::device_vector<float> vector;
std::function<void>(vector&) f;
f = [](vector & veh)->void
{   
    thrust::transform( veh.begin(), veh.end(), veh.begin(), tanh_f() );
};

To no avail. However, if I just use the lambda (without the std::function) it works:

typedef typename thrust::device_vector<float> vector;
auto f = [](vector & veh)->void
{   
    thrust::transform( veh.begin(), veh.end(), veh.begin(), tanh_f() );
};

What am I missing? PS: I am compiling using nvcc release 6.5, V6.5.12 and g++ (Debian 4.8.4-1) 4.8.4

Aucun commentaire:

Enregistrer un commentaire