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
#include <cstdint>
#include <string>
#include <vector>
+12 -8
View File
@@ -1,20 +1,24 @@
#include "print_and_format.hpp"
#include <ranges>
#include <sstream>
namespace cpp23 {
auto format_greeting(const std::string& name, int score) -> std::string {
(void)name; (void)score;
return {};
auto format_greeting(const std::string& name, const int score) -> std::string {
return std::format("{} scored {} points", name, score)
| std::ranges::to<std::string>();
}
auto format_table_row(const std::vector<std::string>& columns) -> std::string {
(void)columns;
return {};
return columns
| std::views::join_with(std::string_view{" | "})
| std::ranges::to<std::string>();
}
auto format_hex(std::uint32_t value) -> std::string {
(void)value;
return {};
auto format_hex(const std::uint32_t value) -> std::string {
return std::format("0x{:X}", value)
| std::ranges::to<std::string>();
}
} // namespace cpp23