this week
Something really interesting this week was function overloading with r-value references. I didn’t know you could write a function that takes an int&&, which only accepts r-values, so passing in a normal variable won’t even compile. Overloading it next to int& and const int& lets the compiler pick a different function depending on what you pass in, which is also how move constructors get called instead of copy constructors.
I also learned more about initializer lists and how some of these classes are implemented underneath. The difference between std::vector<int> x(2) and std::vector<int> x{2} confused me at first, but it makes sense that {} is a list of items while () is more like the arguments, or the count of items for vectors at least.
The paper this week on the Dependency Inversion Principle was about making high level code depend on abstractions instead of low level details, so you can swap out the details without touching the code that matters. I can see why that’s important in larger codebases where things change all the time.
working with the AI
For Project #3: Allocator, I worked with Claude Code to write DESIGN.md and CRITERIA.md before any code. I was surprised by how good the model was at inferring what I wanted and getting the design right. It even caught an ambiguity in the problem statement about how leftover space is measured, which we then confirmed on HackerRank.
There were still times I had to step in. When HackerRank wouldn’t compile, I had to tell it the newest option was C++20, not C++23. I also told it to reference my previous projects for the README.
Testing is where it really shined. It kept testing until everything was correct, even making broken versions of the allocator on purpose to check that the tests catch them, and adding more tests when they didn’t.
