Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved LRU cache implementation to separate files #30218

Merged
merged 2 commits into from
May 4, 2019

Conversation

ZhilkinSerg
Copy link
Contributor

Summary

SUMMARY: Infrastructure "Moved LRU cache implementation to separate files"```

Purpose of change

We would probably like to use LRU cache not only for map memory, but for other things too.

Describe the solution

Updated templates of LRU cache implementation, so it could be used with different key types and moved it to separate files.

@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style labels May 3, 2019
@kevingranade kevingranade merged commit 2e4aa2a into CleverRaven:master May 4, 2019
@jbytheway
Copy link
Contributor

The extern template lines should remain in map_memory.h.

@ZhilkinSerg
Copy link
Contributor Author

What would be the benefit?

@ZhilkinSerg ZhilkinSerg deleted the lru-cache branch May 4, 2019 08:06
@jbytheway
Copy link
Contributor

When you have explicit instantiations (as lru_cache.cpp has) you should have the extern template lines to declare them in a header. It tells the compiler "don't worry about instantiating this template; I've arranged for this to happen elsewhere".

Honestly, I was a bit surprised that this compiles at all, because of the implementation of lru_cache being not in the header. Looking into it a bit more, I see that extern template is a new feature in C++11 so I guess it is supposed to be able to work like this; the compiler's just trusting you to do the right thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants