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