serge-sans-paille / frozen

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

frozen::unordered_multiset? #114

Open davidson16807 opened 3 years ago

davidson16807 commented 3 years ago

What would be required to create the frozen equivalent of unordered_multiset?

I'm asking since I think the existence of such a thing could allow for creating nice and easy compile-time unit libraries akin to mpusz/units or benri:

constexpr frozen::unordered_multiset<frozen::string, int, 1> mass = {{"mass", 1}};
constexpr frozen::unordered_multiset<frozen::string, int, 2> acceleration = {{"length", 1}, {"time", -2}};
constexpr auto force = combine(mass, acceleration);

Personally, if I'm writing a software framework that relies on a dimensional type system I'd much rather rely on a low lying abstraction like a frozen::unordered_multiset rather than force users to add one of these units libraries to their list of dependencies.

serge-sans-paille commented 3 years ago

Let's consider the case of an unordered_multimap that brings the unordered_multiset for free. An option could be to implement it as an unordered_multimap with a cvector with the appropriate bound derived from the intializer.