Solved: 10 - Function Basics
This commit is contained in:
@@ -1,10 +1,26 @@
|
|||||||
#include "function_basics.hpp"
|
#include "function_basics.hpp"
|
||||||
|
|
||||||
|
#include <ranges>
|
||||||
|
|
||||||
namespace functions {
|
namespace functions {
|
||||||
|
|
||||||
auto square(int value) -> int { (void)value; return 0; }
|
auto square(const int value) -> int {
|
||||||
void swap_integers(int& lhs, int& rhs) { (void)lhs; (void)rhs; }
|
return value * value;
|
||||||
auto concatenate(const std::vector<std::string>& parts) -> std::string { (void)parts; return {}; }
|
}
|
||||||
void append_suffix(std::string& text, const std::string& suffix) { (void)text; (void)suffix; }
|
|
||||||
|
void swap_integers(int& lhs, int& rhs) {
|
||||||
|
const int tmp = lhs;
|
||||||
|
lhs = rhs;
|
||||||
|
rhs = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto concatenate(const std::vector<std::string>& parts) -> std::string {
|
||||||
|
return std::ranges::to<std::string>(std::views::join(parts));
|
||||||
|
}
|
||||||
|
|
||||||
|
void append_suffix(std::string& text, const std::string& suffix) {
|
||||||
|
// The string is passed by reference, so it can have text appended
|
||||||
|
text += suffix;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace functions
|
} // namespace functions
|
||||||
|
|||||||
Reference in New Issue
Block a user