I want to implement a custom collection data structure in std style. There is already a similar question on this site, but this guy is explicitly asking about not using any given std functionality.
The implementation should be compatible with the rest of the standard library and provide the same interface, for example iterators and type traits. Which base class should I inherit from and what does my class have to implement?
To provide information about the actual data structure, it is a hash map which values are stored continuously in memory. Internally, I will use two std::vectors and one std::unordered_map.
Which base class should I inherit from
None. Standard containers are not polymorphic; their interface requirements are informally specified in terms of expressions that must be supported. (In the future, they might be formally specified as "concepts"; but that's not part of the language yet.)
what does my class have to implement?
See the [container.requirements] section of the C++ standard (currently section 23.2 of C++11); in particular the tables specifying the operations that various container types must support. As a hash map, it should support the requirements for "unordered associative containers".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With