mercredi 25 février 2015

R-value Reference push_back Function

I'm writing a Queue class. I have two versions of push_back for the new C++11 standard. One of these versions uses a rvalue reference as a parameter. My version works, but I think it must be lacking something:



97 template <typename T>
98 void Queue<T>::push( T && val )
99 {
100 c.push_back( val );
101 }


It seems I should have used std::move, but I'm not sure how to implement this. c in the above function refers to a deque object encapsulated in my Queue class. Any help understanding what I should do to construct this function appropriately would be much appreciated!


Aucun commentaire:

Enregistrer un commentaire