| 9 | template <typename T> const T* larger(const std::vector<T>& data); |
| 10 | |
| 11 | int main() |
| 12 | { |
| 13 | int big_int {17011983}, small_int {10}; |
| 14 | std::cout << std::format("Larger of {} and {} is {}", |
| 15 | big_int, small_int, larger(big_int, small_int)) << std::endl; |
| 16 | std::cout << std::format("Larger of {} and {} is {}", |
| 17 | big_int, small_int, *larger(&big_int, &small_int)) << std::endl; |
| 18 | |
| 19 | std::vector<double> data {-1.4, 7.3, -100.0, 54.1, 16.3}; |
| 20 | std::cout << "The largest value in data is " << *larger(data) << std::endl; |
| 21 | |
| 22 | std::vector<std::string> words {"The", "higher", "the", "fewer"}; |
| 23 | std::cout << std::format(R"(The largest word in words is "{}")", *larger(words)) |
| 24 | << std::endl; |
| 25 | } |
| 26 | |
| 27 | // Template for functions to return the larger of two values |
| 28 | template <typename T> |