TU-Programmieren_2/lab3/taskC.two.hpp
2025-04-09 10:22:44 +02:00

27 lines
487 B
C++

/// @file
/// @brief task C: function templates
#pragma once
#include <vector>
namespace two {
/// @todo: implement ONE function template covering the function overloads 'one::add'
/// @todo: implement ONE function template covering the function overloads 'one::sum'
template <typename T>
T add(const T& a, const T& b) {
return a + b;
}
template <typename T>
T sum(const std::vector<T>& vec) {
T res = 0;
for (T x : vec) {
res += x;
}
return res;
} // namespace two