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 "auto_and_range_for.hpp"
#include <algorithm>
namespace cpp11 { namespace cpp11 {
auto double_values(const std::vector<int>& input) -> std::vector<int> { auto double_values(const std::vector<int>& input) -> std::vector<int> {
(void)input; auto result = std::vector<int>{};
return {}; 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 { auto join_with_auto(const std::vector<std::string>& parts) -> std::string {
(void)parts; auto result = std::string{};
return {}; std::ranges::for_each(parts, [&result](const std::string& part) { result += part; });
return result;
} }
auto count_if_positive(const std::vector<int>& input) -> int { auto count_if_positive(const std::vector<int>& input) -> int {
(void)input; auto count = 0;
return 0; std::ranges::for_each(input, [&count](const int value) { if (value > 0) ++count; });
return count;
} }
} // namespace cpp11 } // namespace cpp11