-
Notifications
You must be signed in to change notification settings - Fork 215
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
[map] Consider adding a default-constructor #197
Comments
For a map whose keys are types and values are default constructible containers, it would be cool if the containing map itself was default constructible. In my case I am creating a reusable type from an external function that takes parameters that I would have to capture otherwise. My current workaround is to pass around a tuple of pairs type and convert it to a map in the constructor which is less convenient. Please consider this simplified use case:
Let me know if this is just crazy or if I am abusing decltype here. I was originally doing something like this with C 11 std::tuples, and it was not pretty :). |
Incidentally I realized I can also use |
I made three tests using variations of a
Here is the resulting target sizes compiled with
I'm trying to understand what is going on here. The third example is pretty extreme so I'll do more to check that the object creation isn't completely obviated. Here is the source code:
I have a cmake file and the modified map.hpp, if you want the whole thing in a Gist or something. lmk |
First of all, That being said, I would argue that there's both a compiler QOI issue behind this, and a user abuse. In other words, no matter how clever the compiler and Hana are, you're still placing 500 |
Yeah, if I change it to just Sorry if I am being a pest. I think I'm going to make a separate project just for testing this kind of stuff. Would you mind if I asked something like this as a question on StackOverflow.com? |
I made some experiments, and basically the same thing happens if you have a struct holding 500 pairs. If you hold 500 vectors, the code is still shitty but it's better. However, when you have a
Sure, go ahead. |
@ricejasonf Hey, I think I found what was the problem. The bloat is probably due to the symbol of the constructor and destructors of the |
I gave it a shot with Back to the original issue, the only reason I see for a map default constructor is convenience, and the only place I am using it is in a wrapper class. A wrapper class that since refactoring to use Hana, I can see that I could eliminate it in favor of using the map directly and probably save myself some bloat in the process. That said, I'd be fine if you wanted to deem it unnecessary for now and close this. |
Can you please put the whole thing in a Gist? I'd like to try it on my side. It's a rather annoying issue, and I think I've got a library-based fix if |
https://gist.github.com/ricejasonf/c2cd831d207912583549 |
Requested in the chat.
The text was updated successfully, but these errors were encountered: