title: Thrust vector with custom data type
body: <p>I am using the thrust library for my project and ran into the following problem:</p>
  
  <p>I have a struct called box defined as</p>
  
  <pre><code>typedef struct {
      int coord[4];
      float h;
  } box;
  </code></pre>
  
  <p>and am now trying to copy data from a device_vector of boxes to a host_vector of boxes:</p>
  
  <pre><code>thrust::device_vector&lt;box&gt; d_boxes(100);
  thrust::host_vector&lt;box&gt; h_boxes;
  thrust::copy(d_boxes.begin(), d_boxes.end(), h_boxes.begin());
  </code></pre>
  
  <p>But this throws the error</p>
  
  <blockquote>
    <p>terminate called after throwing an instance of 'thrust::system::system_error'
    what():  invalid argument</p>
  </blockquote>
  
  <p>If I do the same with int instead of box, it works fine.
  Unfortunately, the documentation does not seem to have any example of vectors of custom data types.</p>
  
  <p>What did I miss?</p>