jeudi 24 septembre 2020

Returning T(t) with T=int&, how?

template<typename T>
T foo(T&& t) {
    return T(t);
}

int main() {
    int x;
    foo(x);
}

So, I know T=int& here but I don't understand what happens at return line to make this vaild. Can someone explain how?

Aucun commentaire:

Enregistrer un commentaire