1 year ago
#326496
Lewis Chan
use unordered_set<T> or unordered_set<T*>?
If we use unordered_set<T>
(T
is custom type, not simple type), it's quite likely that we need define custom operator==
and hasher, which is kind of cumbersome if we have lots of different T
in a big project. Furthermore how to choose a good hash function is a big issue.
But if we use unordered_set<T*>
(including smart pointer), we can omit those definitions. Especially I find in rocksdb and mysql-server codebase, lots of unordered_set<T*>
are used instead of unordered_set<T>
, whereas in mongodb and scylladb, lots of unordered_set<T>
defined. This situation gives me impression that rocksdb developers seems intentionally to avoid using unordered_set<T>
?
So I'm a little confused when to use unordered_set<T>
and when use unorderd_set<T*>
?
c++
unordered-set
0 Answers
Your Answer