title: NVidia Thrust device_vector of strings
body: <p>I started using the NVidia Thrust library which comes as part of the CUDA 4.0 toolkit and wanted to verify something before digging deeper.  I can perform the following and have no issues during build:</p>
  
  <pre><code>thrust::host_vector &lt;int&gt; iVec;
  thrust::device_vector &lt;int&gt; iVec2;
  thrust::host_vector &lt;std::string&gt; sVec;
  </code></pre>
  
  <p>When I try the following I get a compilation error:</p>
  
  <pre><code>    thrust::device_vector &lt;std::string&gt; sVec2;
  </code></pre>
  
  <p>What I would like to know is can I assume any data type I can use in an STL vector should be useable in a thrust vector irrespective of whether it's device or host?  Or are there limitations here and I shouldn't expect this to work?</p>
  
  <p>The error I get is the following:</p>
  
  <p>c:\program files\nvidia gpu computing toolkit\cuda\v4.0\include\thrust\detail\device\cuda\for_each.inl(93): error C2027: use of undefined type 'thrust::detail::STATIC_ASSERTION_FAILURE'
  1>          with
  1>          [
  1>              x=false
  1>          ]
  1>          c:\program files\nvidia gpu computing toolkit\cuda\v4.0\include\thrust\detail\device\dispatch\for_each.h(56) : see reference to function template instantiation 'RandomAccessIterator thrust::detail::device::cuda::for_each_n(RandomAccessIterator,Size,UnaryFunction)' being compiled
  1>          with
  1>          [
  1>              RandomAccessIterator=thrust::detail::normal_iterator>,
  1>              Size=__w64 int,
  1>              UnaryFunction=thrust::detail::device_destroy_functor
  1>          ]
  1>          c:\program files\nvidia gpu computing toolkit\cuda\v4.0\include\thrust\detail\device\for_each.inl(43) : see reference to function template instantiation 'RandomAccessIterator thrust::detail::device::dispatch::for_each_n(RandomAccessIterator,Size,UnaryFunction,thrust::detail::cuda_device_space_tag)' being compiled
  1>          with
  1>          [
  1>              RandomAccessIterator=thrust::detail::normal_iterator>,
  1>              OutputIterator=thrust::detail::normal_iterator>,
  1>              Size=__w64 int,
  1>              UnaryFunction=thrust::detail::device_destroy_functor
  1>          ]
  1>          c:\program files\nvidia gpu computing toolkit\cuda\v4.0\include\thrust\detail\device\for_each.inl(54) : see reference to function template instantiation 'OutputIterator thrust::detail::device::for_each_n(OutputIterator,Size,UnaryFunction)' being compiled
  1>          with
  1>          [
  1>              OutputIterator=thrust::detail::normal_iterator>,
  1>              InputIterator=thrust::detail::normal_iterator>,
  1>              UnaryFunction=thrust::detail::device_destroy_functor,
  1>              Size=__w64 int
  1>          ]
  1>          c:\program files\nvidia gpu computing toolkit\cuda\v4.0\include\thrust\detail\dispatch\for_each.h(72) : see reference to function template instantiation 'InputIterator thrust::detail::device::for_each(InputIterator,InputIterator,UnaryFunction)' being compiled
  1>          with
  1>          [
  1>              InputIterator=thrust::detail::normal_iterator>,
  1>              UnaryFunction=thrust::detail::device_destroy_functor
  1>          ]
  1>          c:\program files\nvidia gpu computing toolkit\cuda\v4.0\include\thrust\detail\for_each.inl(51) : see reference to function template instantiation 'InputIterator thrust::detail::dispatch::for_each(InputIterator,InputIterator,UnaryFunction,thrust::device_space_tag)' being compiled
  1>          with
  1>          [
  1>              InputIterator=thrust::detail::normal_iterator>,
  1>              UnaryFunction=thrust::detail::device_destroy_functor
  1>          ]
  1>          c:\program files\nvidia gpu computing toolkit\cuda\v4.0\include\thrust\detail\for_each.inl(67) : see reference to function template instantiation 'InputIterator thrust::detail::for_each(InputIterator,InputIterator,UnaryFunction)' being compiled
  1>          with
  1>          [
  1>              InputIterator=thrust::detail::normal_iterator>,
  1>              UnaryFunction=thrust::detail::device_destroy_functor
  1>          ]
  1>          c:\program files\nvidia gpu computing toolkit\cuda\v4.0\include\thrust\detail\dispatch\destroy.h(59) : see reference to function template instantiation 'void thrust::for_each>(InputIterator,InputIterator,UnaryFunction)' being compiled
  1>          with
  1>          [
  1>              ForwardIterator=thrust::detail::normal_iterator>,
  1>              T=value_type,
  1>              InputIterator=thrust::detail::normal_iterator>,
  1>              UnaryFunction=thrust::detail::device_destroy_functor
  1>          ]
  1>          c:\program files\nvidia gpu computing toolkit\cuda\v4.0\include\thrust\detail\destroy.h(42) : see reference to function template instantiation 'void thrust::detail::dispatch::destroy(ForwardIterator,ForwardIterator,thrust::detail::false_type)' being compiled
  1>          with
  1>          [
  1>              ForwardIterator=thrust::detail::normal_iterator>
  1>          ]
  1>          c:\program files\nvidia gpu computing toolkit\cuda\v4.0\include\thrust\detail\vector_base.inl(442) : see reference to function template instantiation 'void thrust::detail::destroy>(ForwardIterator,ForwardIterator)' being compiled
  1>          with
  1>          [
  1>              Pointer=thrust::device_ptr,
  1>              ForwardIterator=thrust::detail::normal_iterator>
  1>          ]
  1>          c:\program files\nvidia gpu computing toolkit\cuda\v4.0\include\thrust\detail\vector_base.inl(440) : while compiling class template member function 'thrust::detail::vector_base::~vector_base(void)'
  1>          with
  1>          [
  1>              T=std::string,
  1>              Alloc=thrust::device_malloc_allocator
  1>          ]
  1>          c:\program files\nvidia gpu computing toolkit\cuda\v4.0\include\thrust\device_vector.h(55) : see reference to class template instantiation 'thrust::detail::vector_base' being compiled
  1>          with
  1>          [
  1>              T=std::string,
  1>              Alloc=thrust::device_malloc_allocator
  1>          ]
  1>          c:\users\fsquared\mydata\idata\main.cpp(119) : see reference to class template instantiation 'thrust::device_vector' being compiled
  1>          with
  1>          [
  1>              T=std::string
  1>          ]
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========</p>
  
  <p>I am using MSCV 2010 here.</p>