diff --git a/homework/vector-of-shared-ptrs/vectorFunctions.cpp b/homework/vector-of-shared-ptrs/vectorFunctions.cpp new file mode 100644 index 00000000..4a7f654a --- /dev/null +++ b/homework/vector-of-shared-ptrs/vectorFunctions.cpp @@ -0,0 +1,39 @@ +#include "vectorFunctions.hpp" + +std::vector> generate(int count) { + std::vector> vec; + + for (size_t i = 0; i < count; i++) { + vec.push_back(std::make_shared(i)); + } + + return vec; +} + +void print(const std::vector>& vec) { + for (auto& item : vec) { + std::cout << *item << "\n"; + } +} + +void add10(const std::vector>& vec) { + for (auto& item : vec) { + if (item) { + *item += 10; + } + } +} + +void sub10(int* num) { + if (num) { + *num -= 10; + } +} + +void sub10(const std::vector>& vec) { + for (auto& item : vec) { + if (item) { + *item -= 10; + } + } +} diff --git a/homework/vector-of-shared-ptrs/vectorFunctions.hpp b/homework/vector-of-shared-ptrs/vectorFunctions.hpp new file mode 100644 index 00000000..d58bd97c --- /dev/null +++ b/homework/vector-of-shared-ptrs/vectorFunctions.hpp @@ -0,0 +1,14 @@ +#pragma once +#include +#include +#include + +std::vector> generate(int count); + +void print(const std::vector>& vec); + +void add10(const std::vector>& vec); + +void sub10(int* num); + +void sub10(const std::vector>& vec);