CSChris Spicerinchrisspicer.hashnode.dev·Sep 13, 2024 · 2 min readHow the C++ Multimap handles Identical ValuesThe std::multimap can hold multiple values associated with the same key. This differentiates it from std::map, which can only have one value per key. When an item is inserted into the multimap, it will typically be ordered by its key. I then had the ...00
CSChris Spicerinchrisspicer.hashnode.dev·May 18, 2023 · 2 min readWhen White Dwarf magazine published CodeI have a Warhammer habit. I was introduced to the hobby by my older brother in the mid-1980s, so I have an affection for issues of White Dwarf magazine from that era. For those not aware: Games Workshop produce the Warhammer table-top wargame and als...00
CSChris Spicerinchrisspicer.hashnode.dev·May 18, 2023 · 2 min readVector CapacityThe vector capacity function returns the memory size of the vector, expressed in terms of the size of the elements. The capacity can be equal to or larger than the size of the vector, as demonstrated by this code: std::vector<int> v; std::cout << "S...00
CSChris Spicerinchrisspicer.hashnode.dev·Jan 4, 2022 · 2 min readInvalidating Iterators for Fun and ProfitThe following code throws a Read Access Violation exception: std::vector<int> v{ 1, 2, 3, 4, 5 }; std::vector<int>::iterator it = v.begin(); std::cout << "Iterator value: " << *it << "\n"; v.push_back(6); std::cout << "Iterator value: " << *it << "\...00
CSChris Spicerinchrisspicer.hashnode.dev·Dec 20, 2021 · 1 min readCalling Virtual Functions in ConstructorsVirtual functions are easy to understand, but there are some situations where they can catch you out. Calling virtual functions from Constructors is one of those situations. Take the following code as an example: class BaseClass { public: BaseCla...00