serge-sans-paille / frozen

a header-only, constexpr alternative to gperf for C++14 users
Apache License 2.0
1.27k stars 103 forks source link

Add frozen::invert_unordered_map function and tests #146

Closed justusranvier closed 1 year ago

justusranvier commented 1 year ago

Creates a (value, key) map from an existing (key, value) map.

serge-sans-paille commented 1 year ago

Thanks for this patch! I try to stick to std:: api for frozen, and to my knowledge, invert_unordered_map is not a standard function and it probably makes sense to keep it in client code. If more functions like this are contributed, we could imagine a frozen_extra repo?

justusranvier commented 1 year ago

Inverting a map is a common operation and it doesn't make sense to me that everybody who needs to do it should have to write their own function for it.

If it's not something you want in your repo though it's not the end of the world.

justusranvier commented 11 months ago

If more functions like this are contributed, we could imagine a frozen_extra repo?

Would you accept an updated version of this pull request if the function was placed in a new header frozen/contrib/invert.h?

The contrib directory could allow for other functions to be added in the future which are not part of the official api but still get packaged together for ease of testing and distribution.