Initial Course

This commit is contained in:
David Gil de Gómez Pérez
2026-08-11 17:40:36 +03:00
commit 9aed1d1d86
202 changed files with 3420 additions and 0 deletions
@@ -0,0 +1,12 @@
#pragma once
#include <array>
#include <cstddef>
namespace cpp26 {
[[nodiscard]] auto compile_time_factorial(int n) -> long long;
[[nodiscard]] auto compile_time_sum(std::array<int, 5> values) -> int;
[[nodiscard]] auto is_sorted(std::array<int, 5> values) -> bool;
} // namespace cpp26
@@ -0,0 +1,24 @@
#pragma once
#include <format>
#include <string>
namespace cpp26 {
struct Point {
int x;
int y;
};
[[nodiscard]] auto format_point(const Point& point) -> std::string;
[[nodiscard]] auto format_points(const Point& a, const Point& b) -> std::string;
} // namespace cpp26
template <>
struct std::formatter<cpp26::Point> : std::formatter<std::string> {
auto format(const cpp26::Point& point, std::format_context& ctx) const {
return std::formatter<std::string>::format(
std::format("({}, {})", point.x, point.y), ctx);
}
};
@@ -0,0 +1,14 @@
#pragma once
#include <expected>
#include <string>
namespace cpp26 {
enum class ErrorCode { NotFound, Invalid };
[[nodiscard]] auto parse_id(const std::string& text) -> std::expected<int, ErrorCode>;
[[nodiscard]] auto load_user(int id) -> std::expected<std::string, ErrorCode>;
[[nodiscard]] auto load_user_name(const std::string& text) -> std::expected<std::string, ErrorCode>;
} // namespace cpp26
@@ -0,0 +1,18 @@
#pragma once
#include <string>
#include <vector>
namespace cpp26 {
struct Record {
std::string category;
int value;
};
[[nodiscard]] auto top_values_by_category(const std::vector<Record>& records, int min_value)
-> std::vector<Record>;
[[nodiscard]] auto total_by_category(const std::vector<Record>& records)
-> std::vector<std::pair<std::string, int>>;
} // namespace cpp26