title: How to shuffle a std::vector?
body: <p>I am looking for a generic, reusable way to shuffle a <code>std::vector</code> in C++. This is how I currently do it, but I think it's not very efficient because it needs an intermediate array and it needs to know the item type (DeckCard in this example):</p>
  
  <pre><code>srand(time(NULL));
  
  cards_.clear();
  
  while (temp.size() &gt; 0) {
      int idx = rand() % temp.size();
      DeckCard* card = temp[idx];
      cards_.push_back(card);
      temp.erase(temp.begin() + idx);
  }
  </code></pre>