Initial Course
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <concepts>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace cpp20 {
|
||||
|
||||
template <std::integral T>
|
||||
[[nodiscard]] auto double_value(T value) -> T {
|
||||
(void)value;
|
||||
return T{};
|
||||
}
|
||||
|
||||
template <std::floating_point T>
|
||||
[[nodiscard]] auto clamp01(T value) -> T {
|
||||
(void)value;
|
||||
return T{};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
concept StringLike = requires(T value) {
|
||||
{ value.size() } -> std::convertible_to<std::size_t>;
|
||||
{ value.data() } -> std::convertible_to<const char*>;
|
||||
};
|
||||
|
||||
template <StringLike T>
|
||||
[[nodiscard]] auto uppercase_copy(const T& text) -> std::string {
|
||||
(void)text;
|
||||
return {};
|
||||
}
|
||||
|
||||
[[nodiscard]] auto sum_integral(const std::vector<int>& data) -> int;
|
||||
|
||||
} // namespace cpp20
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <ranges>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace cpp20 {
|
||||
|
||||
[[nodiscard]] auto even_numbers(const std::vector<int>& input) -> std::vector<int>;
|
||||
[[nodiscard]] auto take_first_three(const std::vector<int>& input) -> std::vector<int>;
|
||||
[[nodiscard]] auto join_strings(const std::vector<std::string>& parts) -> std::string;
|
||||
|
||||
} // namespace cpp20
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <compare>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace cpp20 {
|
||||
|
||||
struct Version {
|
||||
int major;
|
||||
int minor;
|
||||
int patch;
|
||||
|
||||
[[nodiscard]] auto operator<=>(const Version& other) const = default;
|
||||
};
|
||||
|
||||
[[nodiscard]] auto sort_versions(std::vector<Version> versions) -> std::vector<Version>;
|
||||
[[nodiscard]] auto is_sorted_versions(const std::vector<Version>& versions) -> bool;
|
||||
|
||||
} // namespace cpp20
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
namespace cpp20 {
|
||||
|
||||
[[nodiscard]] auto span_sum(std::span<const int> data) -> int;
|
||||
[[nodiscard]] auto first_and_last(std::span<const int> data) -> std::pair<int, int>;
|
||||
[[nodiscard]] auto make_subspan(std::span<const int> data, std::size_t offset, std::size_t count)
|
||||
-> std::vector<int>;
|
||||
|
||||
} // namespace cpp20
|
||||
Reference in New Issue
Block a user