Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dwarfovich committed Sep 14, 2024
1 parent 721ada6 commit c0d6a9b
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions HW3/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ template<typename T>
T factorial(T n)
{
if (n < 0) {
return 0;
throw std::invalid_argument("n have to be greater or equal to 0");
}

if (n == 0 || n == 1) {
Expand Down Expand Up @@ -48,7 +48,26 @@ int main()
}

cc::ForwardList<int> list;

auto iter = list.cbefore_begin();
for(int i = 0; i < 10; ++i){
iter = list.insert_after(iter, factorial(i));
}
std::cout << "Custom container with std::allocator:\n";
int counter = 0;
for( auto i : list){
std::cout << counter++ << ": " << i << '\n';
}

cc::ForwardList<int, MMA> mmList;
auto mmIter = mmList.cbefore_begin();
for (int i = 0; i < 10; ++i) {
mmIter = mmList.insert_after(mmIter, factorial(i));
}
std::cout << "Custom container with custom allocator:\n";
int mmCounter = 0;
for (auto i : mmList) {
std::cout << mmCounter++ << ": " << i << '\n';
}

return 0;
}

0 comments on commit c0d6a9b

Please sign in to comment.