Solved: 41 - Structured Bindings

This commit is contained in:
2026-08-22 10:16:53 +03:00
parent b4a46bece7
commit 29df33a4e9
+18 -6
View File
@@ -1,20 +1,32 @@
#include "structured_bindings.hpp"
#include <ranges>
namespace cpp17 {
auto minmax_pair(const std::vector<int>& data) -> std::pair<int, int> {
(void)data;
return {0, 0};
auto min = std::numeric_limits<int>::max();
auto max = std::numeric_limits<int>::min();
for (const auto i : data) {
if (i < min) min = i;
if (i > max) max = i;
}
return {min, max};
}
auto split_key_value(const std::string& text) -> std::pair<std::string, std::string> {
(void)text;
return {"", ""};
auto r = std::views::split(text, '=');
auto it = r.begin();
auto key = *it | std::ranges::to<std::string>();
++it;
auto value = *it | std::ranges::to<std::string>();
return {key, value};
}
auto first_pair(const std::map<std::string, int>& scores) -> std::tuple<std::string, int, bool> {
(void)scores;
return {"", 0, false};
if (scores.empty()) return {"", 0, false};
const auto& [name, score] = *scores.begin();
return {name, score, true};
}
} // namespace cpp17