|
|
|
|
|
by caseyy
497 days ago
|
|
Also, simple is evident, smooth, maintainable, and fast. If asked to implement a templated dictionary type, many C++ programmers will write a templated class. If they want to be responsible, they’ll write unit tests. But the simplest way is: template<typename Key, typename Value> using Dictionary = std::vector<std::pair<Key, Value>>; It is trivially correct and won’t have any edge cases which the tests may or may not catch. Some programmers would consider this implementation beneath them. In just 800 lines, they could build the type from scratch and with only a few months’ long tail of bugs. |
|