title: How to use Thrust to implement reduce by key when keys are strings or char array
body: <p>input: </p>
  
  <blockquote>
    <p>BC<br>
    BD<br>
    BC<br>
    BC<br>
    BD<br>
    CD<br></p>
  </blockquote>
  
  <p>output:</p>
  
  <blockquote>
    <p>BC 3<br>
    BD 2<br>
    CD 1<br></p>
  </blockquote>
  
  <p>if I use char type as key it is available.But seems Thrust does not support string as a key.</p>
  
  <pre><code>#include &lt;thrust/device_vector.h&gt;
  #include &lt;thrust/iterator/constant_iterator.h&gt;
  #include &lt;thrust/reduce.h&gt;
  #include &lt;string&gt;
  
  int main(void)
  {
    std::string data = "aaabbbbbcddeeeeeeeeeff";
  
    size_t N = data.size();
  
    thrust::device_vector&lt;char&gt; input(data.begin(), data.end());
  
    thrust::device_vector&lt;char&gt; output(N);
    thrust::device_vector&lt;int&gt;  lengths(N);
  
    size_t num_runs =
      thrust::reduce_by_key(input.begin(), input.end(),        
                        thrust::constant_iterator&lt;int&gt;(1), 
                        output.begin(),                    
                        lengths.begin()                    
                        ).first - output.begin();
     return 0;
  }
  </code></pre>
  
  <p>How to implement it using Thrust?</p>