lundi 16 septembre 2019

Can we have a C++ function with multiple return types? ( C++11 and above)

I am trying to write a generic function which takes input as uint8, uint16, uint32, uint64, .... and return the maximum value with datatype of largest element?

For example:

template < typename T, typename X>
auto Max_Number ( T valueA, X valueB ){
 if ( valueA > valueB ) 
      return valueA;
else
      return valueB;
}

P.S: this example assumes the largest element is of largest datatype.

Aucun commentaire:

Enregistrer un commentaire