dimanche 27 septembre 2015

C++ std::forward

From what I understand, std::forward<T>(x) is equivalent to static_cast<T&&>(x).

But from what I saw, static_cast<T>(x) seems to do the same thing, as can be seen in the following code

My question is therefore why std::forward<T> is implemented as static_cast<T&&>(x), and not static_cast<T>(x), if both have the same effect?

Aucun commentaire:

Enregistrer un commentaire