I don't understand why the third case is ok (even if the lambda's arguments type is different from the std::function
type are) while the compiler complains with the fourth one:
function<int(int)> idInt = [](int i) {return i;}; //OK
function<int(int&)> idInt = [](int &i) {return i;}; //OK
function<int(int&)> idInt = [](int i) {return i;}; //OK
function<int(int)> idInt = [](int &i) {return i;}; //ERROR!
Aucun commentaire:
Enregistrer un commentaire