Setting each host vector's data element of type int array on device vector

I’m trying to implement the following C++ function on CUDA Thrust:

v

oid setFragment( vector< Atom * > &vStruct, vector< Fragment * > &vFragment ) {
    Fragment *frag;

    int n = vStruct.size();

    for( int i = 0 ; i < n-2 ; i++ ){
        frag = new Fragment();
        frag->index[0] = i;
        frag->index[1] = i+1;   
        frag->index[2] = i+2;   

        vFragment.push_back( frag );    
    }
}

To do so, I created a functor to set indices of each Fragment vector in the following way:

struct setFragment_functor
{
    const int n;

    setFragment_functor(int _n) : n(_n) {}

    __host__ __device__
    void operator() (Fragment *frag) {
        frag->index[0] = n;
        frag->index[1] = n+1;
        frag->index[2] = n+2;       
    }
};

void setFragment( vector< Atom * > &vStruct, vector< Fragment * > &vFragment ) {
    int n = vStruct.size();
    thrust::device_vector<Fragment *> d_vFragment(n-2);

    thrust::transform( d_vFragment.begin(), d_vFragment.end(), setFragment_functor( thrust::counting_iterator<int>(0) ) );

    thrust::copy(d_vFragment.begin(), d_vFragment.end(), vFragment.begin());        
}

However, I’m getting the following errors for the transformation that I applied:

  1. error: no instance of constructor “setFragment_functor::setFragment_functor” matches the argument list
    argument types are: (thrust::counting_iterator<int, thrust::use_default, thrust::use_default, thrust::use_default>)
  2. error: no instance of overloaded function “thrust::transform” matches the argument list
    argument types are: (thrust::detail::normal_iterator<thrust::device_ptr<Fragment *>>, thrust::detail::normal_iterator<thrust::device_ptr<Fragment *>>, )
    I’m new to CUDA. I will appreciate if someone can help me to implement the C++ function on CUDA.