| 21 | std::string largest(std::span<std::string> words); |
| 22 | |
| 23 | int main() |
| 24 | { |
| 25 | double array[] {1.5, 44.6, 13.7, 21.2, 6.7}; |
| 26 | std::vector numbers {15, 44, 13, 21, 6, 8, 5, 2}; |
| 27 | std::vector data{3.5, 5.0, 6.0, -1.2, 8.7, 6.4}; |
| 28 | std::array array_data{ 3.5, 5.0, 6.0, -1.2, 8.7, 6.4 }; // Throwing in an std::array for good measure |
| 29 | std::vector<std::string> names {"Charles Dickens", "Emily Bronte", |
| 30 | "Jane Austen", "Henry James", "Arthur Miller"}; |
| 31 | std::cout << "The largest of array is " << largest(array) << std::endl; |
| 32 | std::cout << "The largest of numbers is " << largest(numbers) << std::endl; |
| 33 | std::cout << "The largest of data is " << largest(data) << std::endl; |
| 34 | std::cout << "The largest of array_data is (also) " << largest(array_data) << std::endl; |
| 35 | std::cout << "The largest of names is " << largest(names) << std::endl; |
| 36 | } |
| 37 | |
| 38 | // Finds the largest of a span of values |
| 39 | double largest(std::span<double> data) |