Write a function template for a function named minimum. The function will have two parameters of the same type. It returns the smaller of these (either if they are equal.)
In carrying this out, give:
a) a prototype (declaration) and preconditions for the function template
b) a definition for this function.
c) As a part of your answer, remark on the restriction of this function template to types for which operator< defined.
a). The declaration and precondition are:
```
// Precondition: T is a type for which operator< is
// defined
// Postcondition: function returns the smaller argument
template
T minimum( T left, T right);
```
b) The definition is:
```
template
T minimum(T left, T right)
{
if ( left < right )
return left;
return right;
}
```
c). The minimum function uses operator<. The compiler will produce an error, and refuse to compile the program if a type is used for which operator< is not defined.
You might also like to view...
The most common problem with thumb drives is inserting them into a powered slot or hub
Indicate whether the statement is true or false
Prior to the 1950s, traditional notions of decency and obscenity were governed by an obscenity statute originally developed in 1868 in Regina v. Hicklin
Indicate whether the statement is true or false.