Solved: 32 - Auto and Range For

This commit is contained in:
2026-08-17 21:30:16 +03:00
parent 8319d391be
commit 3131313253
+12 -6
View File
@@ -1,20 +1,26 @@
#include "auto_and_range_for.hpp"
#include <algorithm>
namespace cpp11 {
auto double_values(const std::vector<int>& input) -> std::vector<int> {
(void)input;
return {};
auto result = std::vector<int>{};
result.reserve(input.size());
std::ranges::for_each(input, [&result](const int value) { result.push_back(value * 2); });
return result;
}
auto join_with_auto(const std::vector<std::string>& parts) -> std::string {
(void)parts;
return {};
auto result = std::string{};
std::ranges::for_each(parts, [&result](const std::string& part) { result += part; });
return result;
}
auto count_if_positive(const std::vector<int>& input) -> int {
(void)input;
return 0;
auto count = 0;
std::ranges::for_each(input, [&count](const int value) { if (value > 0) ++count; });
return count;
}
} // namespace cpp11