Files
cpp-course/modules/03_functions/src/function_basics.cpp
T

27 lines
569 B
C++
Raw Normal View History

2026-08-11 17:40:36 +03:00
#include "function_basics.hpp"
2026-08-12 17:04:54 +03:00
#include <ranges>
2026-08-11 17:40:36 +03:00
namespace functions {
2026-08-12 17:04:54 +03:00
auto square(const int value) -> int {
return value * value;
}
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;
}
2026-08-11 17:40:36 +03:00
} // namespace functions