-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Request: 'emplace_back' #349
Comments
I have to check whether this makes sense, but you're right that not having it, but having |
I think it's considered part of the various "container" concepts (http://en.cppreference.com/w/cpp/concept/SequenceContainer). Having it missing isn't that big a deal, but would be nice. |
Commit 1be73b9 contains a proposal for an It would be nice to discuss this proposal:
|
The implementation looks correct. Although on the one hand I think it's odd for the json object to have both methods, it matches the convention that json has object and array methods and it's up to you to call the right ones. So it looks good to me! |
Thanks. Yes, it is a weird situation to have a combination of a map and a vector, and I am not sure whether users have the mindset "I am using a general container" or rather "I am using an object" / "I am using an array". Another aspect: If there was a single |
Any opinions on this? |
There are times when I wish I had a stronger type that represented what I know it is but I can see the utility of the do-everything type. I dont see a strong reason to change it myself! So The emplace_back would be awesome :) |
Note that std::map::emplace has a return type that is not void. Was it a conscious decision not to do the same in basic_json-object ? |
@TurpentineDistillery Good point! I implemented |
Merged. |
Out of habit, I tend to use 'emplace_back' instead of 'push_back' and I was surprised basic_json didn't support this. Can we add it?
The text was updated successfully, but these errors were encountered: