mercredi 1 juillet 2015

Universal references with functions

What is the type of "univ" in the code below?

template<typename T>
void func(T&& univ) {
    // ??
}

int sum(int a, int b) {
 return a+b;   
}

int main() {

    func(sum);

}

I didn't know that universal references also worked with functions. Is func(sum); equivalent to func(&sum); or is the rvalue reference binding itself to something else than a simple pointer?

Aucun commentaire:

Enregistrer un commentaire