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
+20
View File
@@ -0,0 +1,20 @@
#include "expected.hpp"
namespace cpp23 {
auto parse_int(const std::string& text) -> std::expected<int, ParseError> {
(void)text;
return std::unexpected(ParseError::EmptyInput);
}
auto safe_sqrt(int value) -> std::expected<double, std::string> {
(void)value;
return std::unexpected(std::string{"negative"});
}
auto chain_parse_and_double(const std::string& text) -> std::expected<int, ParseError> {
(void)text;
return std::unexpected(ParseError::InvalidNumber);
}
} // namespace cpp23
+24
View File
@@ -0,0 +1,24 @@
#include "mdspan.hpp"
namespace cpp23 {
auto make_row_major_matrix(int rows, int cols, int fill) -> std::vector<int> {
(void)rows; (void)cols; (void)fill;
return {};
}
auto matrix_element(
std::mdspan<const int, std::extents<int, std::dynamic_extent, std::dynamic_extent>> matrix,
int row, int col) -> int {
(void)matrix; (void)row; (void)col;
return 0;
}
auto row_sums(
std::mdspan<const int, std::extents<int, std::dynamic_extent, std::dynamic_extent>> matrix)
-> std::vector<int> {
(void)matrix;
return {};
}
} // namespace cpp23
+20
View File
@@ -0,0 +1,20 @@
#include "print_and_format.hpp"
namespace cpp23 {
auto format_greeting(const std::string& name, int score) -> std::string {
(void)name; (void)score;
return {};
}
auto format_table_row(const std::vector<std::string>& columns) -> std::string {
(void)columns;
return {};
}
auto format_hex(std::uint32_t value) -> std::string {
(void)value;
return {};
}
} // namespace cpp23
+21
View File
@@ -0,0 +1,21 @@
#include "ranges_zip.hpp"
namespace cpp23 {
auto zip_sum(const std::vector<int>& a, const std::vector<int>& b) -> std::vector<int> {
(void)a; (void)b;
return {};
}
auto chunk_strings(const std::vector<std::string>& words, std::size_t chunk_size)
-> std::vector<std::vector<std::string>> {
(void)words; (void)chunk_size;
return {};
}
auto adjacent_differences(const std::vector<int>& data) -> std::vector<int> {
(void)data;
return {};
}
} // namespace cpp23