Feature request: easier creation of etl::const_maps #1306
relativityspace-jsmith
started this conversation in
General
Replies: 1 comment 4 replies
-
|
Actually I just noticed an even more serious usability problem: const_map works by doing a binary search of the passed elements, and it doesn't re-sort the elements when constructed. So if you happen to construct one with elements that are not already in sorted order, |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Maybe I'm just missing something, but while I love the idea and capabilities of
etl::const_map, I really struggle to actually create them in code.Like, consider the following toy example, where I want to map integers to std::chrono times. So far, the most painless way I've found to do this is:
This works, but there are some pretty major rough edges:
conston either of the template arguments to thepair, compilation fails with a very unhelpful error:This means that anytime I want to create a const_map I have to pull up my existing code and very carefully base my new map on it, staying clear of all these gotchas. It's especially bad since this is the only possible way to create a const_map -- it's not like you can create them element-by-element!
Personally I'd really love if we could get a helper function to create them more easily, maybe something like
etl::make_const_map. So that way you could just do:Beta Was this translation helpful? Give feedback.
All reactions