I usually code in C. Now moving to C++. I have a std::unordered_map with 60 million entries. It is loaded once only and would not be modified later. I would like to pass it to some functions from time to time. But this code would copy the hash map every time:
typedef unordered_map<uint64_t, mer*> mer_map; void test_pass_by_ref3(mer_map kmers) { } void test_pass_by_ref2(mer_map kmers) { test_pass_by_ref3(kmers); } void test_pass_by_ref(mer_map kmers) { test_pass_by_ref2(kmers); } If I want to pass the pointer only, how to pass it and query it as usual: value = mer_map[key]? I searched and find the passing by reference syntax:
void foo(const ClassName &name) { ClassName& temp = const_cast<ClassName&>(name); ... .... } But it seems cannot compiled. Please help. Thanks.