vendredi 6 octobre 2017

Why can auto not be used as a return type for function declaration

This code does not compile (intel icc 15.0.3) with the error message explicit type is missing ("int" assumed)

auto foo(){
     const bool retVal = false;
     return retVal;
}

It can be easily be seen, that the return type in this case is bool. Why can auto not be used as a return type for function declaration? This feature would nicely support the DRY principle.

Aucun commentaire:

Enregistrer un commentaire