Initial C++11 move support#128
Merged
Merged
Conversation
When C++11 is enabled, several algorithms will fail, if GenericValue is neither copyable, nor movable. Cherry-picked from 8005b55.
Directly allows temporary GenericValues as parameters:
v.AddMember("foo", Value(s.c_str(),alloc), alloc);
Added basic detection of `noexcept` support for some compilers, added corresponding RAPIDJSON_NOEXCEPT annotations to * non-allocating constructors * (move) assignment * Swap
Contributor
There was a problem hiding this comment.
I think, this is not noexcept, since it will/can involve a memory allocation...
Contributor
Author
There was a problem hiding this comment.
No, it won't allocate memory. See SetStringRaw (and comment before the constructor).
Contributor
There was a problem hiding this comment.
I mixed that with the version taking the allocator (since I only used that for now)...
* Move() * RawAssign() * SetStringRaw()
* constructor from array is RAPIDJSON_NOEXCEPT * constructor from plain pointer missed an assert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As discussed in 8005b55 and #123, C++11 move support based on rvalue-references would be useful.
This pull-request provides an initial implementation, although restricted to
GenericValueonly. I had a quick look and adding move support to the other classes might not be worth the effort for now.I looked up minimum versions and detection mechanisms for Clang, GCC and MSVC. Users can set
RAPIDJSON_HAS_CXX_*to override the automatic detection of the required features.On a side path, I switched
RAPIDJSON_HAS_STDSTRINGto a symbol that is always available (and either0or1), defaulting to0.There's just the remaining question, whether we want to switch on C++11 mode on travis-ci.org, maybe just for some configurations.