vendredi 25 septembre 2015

Why decltype is used in trailing return types?

consider the following codes:

template< class T1 , class T2>
auto calc( T1 a , T2 b )
{
   return a + b ;
}


template< class T1 , class T2>
auto calc( T1 a , T2 b ) -> decltype( a + b )
{
   return a + b ;
}

Whats the difference in the second code ? Can you give some example where this makes a difference or does it make a difference here ?

Aucun commentaire:

Enregistrer un commentaire