Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#include <unordered_map>
template <typename TKey, typename TValue>
inline std::unordered_map<TKey, TValue> make_dic(typename std::unordered_map<TKey, TValue>::size_type capacity)
{
return std::unordered_map<TKey, TValue>(capacity);
}
...
auto dic = make_dic<std::string, std::string>(1024);
//better than:
//std::unordered_map<std::string, std::string> dic = make_dic<std::string, std::string>(1024);
std::cout << (typeid(dic).name()) << "\n"; //class std::unordered_map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::hash<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,struct std::equal_to<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment