Solved: 48 - Print and Format
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user