Finds the largest of a span of values
| 28 | |
| 29 | // Finds the largest of a span of values |
| 30 | std::optional<double> largest(std::span<const double> data) |
| 31 | { |
| 32 | if (data.empty()) return {}; // Or return std::nullopt; |
| 33 | |
| 34 | double max{ data[0] }; |
| 35 | for (auto value : data) |
| 36 | if (max < value) max = value; |
| 37 | return max; |
| 38 | } |
| 39 | |
| 40 | // Finds the largest of a vector of int values |
| 41 | std::optional<int> largest(std::span<const int> data) |