C++'s implicit copy and move behavior offer an excellent way to shoot yourself in the foot. Here's an example of how they can create a double-free and how to avoid it.
Yeah, that’s confusing to read. A hashset can only contain at most one of each cheese kind, in c++20 you can write inventory.contains(cheeseName), before that you had to use .count or inventory.find(cheeseName) != inventory.end() or something like that
I got stuck on cheese counting:
inventory.count(cheeseName) == 1 ? "Yes" : "No"
1 cheese == some, 2 cheese == none :/
Yeah, that’s confusing to read. A hashset can only contain at most one of each cheese kind, in c++20 you can write
inventory.contains(cheeseName)
, before that you had to use.count
orinventory.find(cheeseName) != inventory.end()
or something like that