Why is this zip iterator not zipping? (Template programming is hard)

Hey Guys,

I’m going to post what works and what doesn’t work and I’m curious as to exactly why I need a typedef to make my code compile.

typedef thrust::device_vector<unsigned>::iterator uint_iter;
typedef thrust::tuple<uint_iter, uint_iter> uint_tuple_iter;

void heart(
           thrust::device_vector<point> &points,
           thrust::device_vector<tetra> &tetras,
           thrust::device_vector<unsigned> &t_association,
           thrust::device_vector<unsigned> &p_association
                                                   ) 

{

    unsigned *t_assoc = thrust::raw_pointer_cast(t_association.data());
    unsigned *p_assoc = thrust::raw_pointer_cast(p_association.data());

    thrust::zip_iterator<uint_tuple_iter> ptet_pair =
            thrust::make_zip_iterator(
                  thrust::make_tuple(t_association.begin(), 
                                     p_association.begin()));
/* ... */
}

The above code compiles and works properly.

But why doesn’t using this instead work?

thrust::zip_iterator<thrust::tuple<thrust::device_vector<unsigned>::iterator, thrust::device_vector<unsigned>::iterator>> ptet_pair = 
            thrust::make_zip_iterator(
                  thrust::make_tuple(t_association.begin(), 
                                     p_association.begin()));

Why do I seem to need a typedef? Is this just a weird template programming thing?

Add a space between the last two > characters in this line:

thrust::zip_iterator<thrust::tuple<thrust::device_vector<unsigned>::iterator, thrust::device_vector<unsigned>::iterator> > ptet_pair =
........................................................................................................................^
........................................................................................................................| here

Are you kidding me? It was a space this whole time? Gah!!!

But in all seriousness, thank you oh so much for the help. I feel like typedefs are so pointless when I only need to use it once.

If you “carefully” inspect the error output, you would see the first line looking something like this:

t467.cu(14): error: space required between adjacent ">" delimiters of ...

I admit it tends to go scrolling off the screen. In that case you could redirect stderr to a file:

nvcc -arch=sm_20 -o t467 t467.cu 2>out.txt