vendredi 16 novembre 2018

What is value_type&& in C++ [duplicate]

This question already has an answer here:

I was looking at the declaration of push_back in vector STL.

void push_back (const value_type& val);
void push_back (value_type&& val);

Questions :

  1. what is && in 2nd declaration?
  2. In first declaration, we are passing by CONST reference val variable. const means that we can't change the val, then why is it being passed as a reference if we don't want to change that. Why it's not declared as void push_back(value_type val)

Aucun commentaire:

Enregistrer un commentaire