Solved: 48 - Print and Format

This commit is contained in:
2026-08-24 18:36:49 +03:00
parent 1e538bdd4b
commit dea138ca04
2 changed files with 13 additions and 8 deletions
@@ -1,5 +1,6 @@
#pragma once #pragma once
#include <cstdint>
#include <string> #include <string>
#include <vector> #include <vector>
+12 -8
View File
@@ -1,20 +1,24 @@
#include "print_and_format.hpp" #include "print_and_format.hpp"
#include <ranges>
#include <sstream>
namespace cpp23 { namespace cpp23 {
auto format_greeting(const std::string& name, int score) -> std::string { auto format_greeting(const std::string& name, const int score) -> std::string {
(void)name; (void)score; return std::format("{} scored {} points", name, score)
return {}; | std::ranges::to<std::string>();
} }
auto format_table_row(const std::vector<std::string>& columns) -> std::string { auto format_table_row(const std::vector<std::string>& columns) -> std::string {
(void)columns; return columns
return {}; | std::views::join_with(std::string_view{" | "})
| std::ranges::to<std::string>();
} }
auto format_hex(std::uint32_t value) -> std::string { auto format_hex(const std::uint32_t value) -> std::string {
(void)value; return std::format("0x{:X}", value)
return {}; | std::ranges::to<std::string>();
} }
} // namespace cpp23 } // namespace cpp23