c++ - std::unordered_set constructors -


i've been looking @ constructors of unordered_set. not possible construct unordered_set custom allocator instance without setting number of hash buckets? i'd rather not mess implementation details because want custom allocator, , type provides no definitions default value. msdn gives 3 overloads constructor, none of terribly useful.

edit: holy crap. stl implementation of std::hash won't specialize strings custom allocator type- can explicit typedefs std::string , std::wstring. mean, can understand not wanting try hash random character strings, because it's got custom allocator? disgusts me.

tokens(std::unordered_set<string>().bucket_count(), std::hash<string>(), std::equal_to<string>(), stl_wrapper::hash_set<string>::allocator_type(this)) template<typename char, typename chartraits, typename allocator> class std::hash<std::basic_string<char, chartraits, allocator>>     : public std::unary_function<std::basic_string<char, chartraits, allocator>, std::size_t> { public:     size_t operator()(const std::basic_string<char, chartraits, allocator>& ref) const {         return std::hash<std::basic_string<char, chartraits>>()(std::basic_string<char, chartraits>(ref.begin(), ref.end()));     } }; 

solves problems, redundant constructions , copying? ewwwww.

that's strange, right. suppose thought it's overkill support possible parameter combinations, defaults.

the best way can think handle construct empty unordered_set default settings, default bucket count using unordered_set::bucket_count, , use input when instantiate container want.

unordered_set<int> temp; size_t buckets = temp.bucket_count; unordered_set<string> actual(buckets, hash(), pred(),      yourallocator(param1 /*, etc */)); 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -