27 lines
487 B
C++
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
|