jeudi 8 août 2019

Do the reference-collapsing rules apply to return type?

The std::forward function template returns T&&. So in order to forward its argument as either an lvalue reference or an rvalue reference, the return type of std::forward must be:

T&& if T is a non-reference type (T && == T&&)
T& if T is an lvalue reference type (T& && == T&)

What I mean is do std::forward's return type changes due to the reference-collapsing rules or the explanation is different?

Is the return type of std::forward a forwarding (universal) reference?

Aucun commentaire:

Enregistrer un commentaire