"thrust::make_transform_iterator" Windows 10 Compile Errors

I’m attempting to build a snippet of code on Windows 10, with the Visual Studio 2015 compiler and CUDA 9.1. The problematic call occurs within thrust::copy_if, which uses thrust::make_transform_iterator to set up its parameters. This code compiles successfully on Linux, on another machine, using gcc and CUDA 9.0/9.1.

#include <iostream>
#include <thrust/copy.h>
#include <thrust/device_vector.h>
#include <thrust/execution_policy.h>
#include <thrust/sequence.h>
#include <thrust/iterator/transform_iterator.h>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/tuple.h>

#define SZ (1024 * 1024)

struct functor {
	const int thresh;
	functor(const int thresh) : thresh(thresh) {};
	__device__ bool operator()(const int i) {
		return i > thresh;

struct transformFunctor {
	__device__ double operator()(const double d) {
		return d + 1.234;

int main(void)
	int threshold;
	thrust::device_vector<double> foo(SZ);
	thrust::device_vector<int> stencil(SZ);
	thrust::device_vector<double> out1(SZ), out2(SZ);

	thrust::sequence(stencil.begin(), stencil.end(), 0, 1);
	thrust::sequence(foo.begin(), foo.end(), 1.4, 3.11);

	threshold = SZ / 2 + 1;
	auto len = thrust::copy_if(thrust::device,
			thrust::make_transform_iterator<transformFunctor, thrust::device_vector<double>::iterator>(foo.begin(), transformFunctor()),
			thrust::make_transform_iterator<transformFunctor, thrust::device_vector<double>::iterator>(foo.end(), transformFunctor()),
			functor(threshold)) - out1.begin();

	return 0;

The build command is the following:

nvcc -G -arch=sm_61 copy_if_compile_tests_new.cu

The error list generated on Windows is here: https://pastebin.com/Bh9LK1SU

I’ve attempted to compile this with both Visual Studio 2015 and 2017, using CUDA 9.0 and 9.1 on a fresh install and seem to generate the same errors. Are there known platform differences that would cause this to fail within Windows but not Linux?

Any assistance would be appreciated.

I’m unable to access pastebin. Long story.

Not an answer to your question, and probably you have already figured this out.

On Windows 7, VS 2015, CUDA 8, I am able to compile your code successfully if I modify this:

struct transformFunctor {

to this:

struct transformFunctor : public thrust::unary_function<double, double> {

BTW I don’t think it should be necessary to manually provide the template parameters for make_transform_iterator, but it’s not germane to this topic I don’t think.

As a further aside, purely conjecture, the error I get is “incomplete type is not allowed”. For me this is a “trigger” to go ahead and decorate my functor with a complete type definition. Conjecture: it would not surprise me if there were implementation differences between (host) compilers in terms of what they will or will not do with incomplete types, or how or to what extent they deduce types.