1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include <iostream>
template < class T, class D >
auto calculate( T a, D b ) -> decltype(a*b) ;
template < class T, class D, class E >
auto calculate( T a, D b, E c ) -> decltype( calculate( calculate(a,b), c ) ) ;
int main()
{
std::cout << calculate( 22, 78.3, 52UL ) << '\n' ;
}
template < class T, class D, class E >
auto calculate( T a, D b, E c ) -> decltype( calculate( calculate(a,b), c ) )
{ return calculate( calculate(a,b), c ) ; }
template < class T, class D >
auto calculate( T a, D b ) -> decltype(a*b) { return a * b ; }
|