-
Notifications
You must be signed in to change notification settings - Fork 2.7k
move ctors #267
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
move ctors #267
Conversation
We still have to consider what to do for the older branch. We maintain strict binary-compatibility with ancient |
Thanks @cdunn2001 ! I see you also fixed my use of |
#endif | ||
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) | ||
#define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I meant to ask: Why was JSON_DEPRECATED dropped for GNUC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did I do that? If so it was in error, sorry.
On 28 April 2015 at 10:51, Christopher Dunn [email protected]
wrote:
In include/json/config.h
#267 (comment)
:#endif
-#elif defined(GNUC) && (GNUC > 4 || (GNUC == 4 && GNUC_MINOR >= 5))
-#define JSONCPP_DEPRECATED(message) attribute ((deprecated(message)))Oh, I meant to ask: Why was JSON_DEPRECATED dropped for GNUC?
—
Reply to this email directly or view it on GitHub
https://github.com/open-source-parsers/jsoncpp/pull/267/files#r29220618.
b68e7cf
to
643cd68
Compare
Asked about backward-compatibility on stackoverflow. |
Answered on stackoverflow (mostly to get feedback from the community as to whether my understanding is correct). |
643cd68
to
e4fb8ce
Compare
Can we add move assignment operators as well, so that we can efficiently do
|
I agree, as in @BillyDonahue comments at #264: class Value {
...
Value(const Value&);
Value(Value&&) noexcept;
Value& operator=(const Value&);
Value& operator=(Value&&) noexcept;
void swap(Value& v) noexcept { std::swap(*this, v); }
friend void swap(Value& a, Value& b) noexcept { a.swap(b); }
}; We also need a macro for #if dumb_compiler
#define noexcept
#endif |
I like the very political references to 'the compilers which do not support'. I actually dug into it and it seems the existing operator= implementations exhibit move semantics, as of 45cd949. Looks like that can be reverted to the old copy semantics with the addition of proper move operators. Regardless of the philosophical motivation behind making copy assignment actually be move assignment. |
I think the direct |
#define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message))) | ||
#elif defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) | ||
#define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__)) | ||
#if defined(_MSC_VER) // MSVC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the reindent be its own PR? It's hard to separate cosmetics from substance as-is.
It would be nice to emphasize the substantive changes with concise PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I'll try re-indent first, and rebase this onto that...
You're probably right; not good in a header.
Yes! I have strong opinions. |
@BillyDonahue, would you pull my code from this branch and add whatever other operators we need? I will take of the |
@akrieger regarding move assignment operator: If you have a look at |
@lanzkron, Do we need any extra methods, beyond what are already in this pull-request? Do we need the move-ctor for CZString at all? I'm not sure where we are. |
@cdunn : I'm still a github noob, but I'm figuring out what you need. I'd like to ask about compatibility again. We are not strictly adding new Old code expecting to find "operator=(Value)" in libjsoncpp.so wouldn't On Wed, Apr 29, 2015 at 12:16 AM, Christopher Dunn <[email protected]
|
@cdunn2001 I'm also new to GitHub, who makes the final call? In my opinion having a move-ctor and keeping the copy/swap assignment operator is good enough. In which case I think we're good to go. Keep in mind that my implementation of I don't currently have the capacity to do this. If that's what we want then we can dump my changes and wait for someone else to code support for move semantics. |
@BillyDonahue, we could remove
We can remove anything in a future 2.0.0 release. At some point, we should move development to a new alpha branch. That's a discussion for another day. @lanzkron, there is no final call. We can always add new features. It's better to add less, because it's hard to remove features. |
@lanzkron ah, yes, you're right, it is a copy and swap. |
@cdunn2001 I assume you mean replacing CZString's operator= with lvalue and rvalue versions, not remove it completely |
Is there any chance of this being merged? It looks a little dead. I'm hoping to have move constructors to greatly improve performance of building a very large json object in pieces, and I found this open pull request. |
e4fb8ce
to
3d5f5c9
Compare
I'm concerned about removing symbols. I don't mind removing them from CZString because nobody who cares about binary compatibility would use it. But I don't think we can remove symbols from Value. I think 1.0 is now used in Debian, e.g. I've just rebased this. Let's take another look now. |
* Add move constructor to Value::CZString * Add unit test for Value move constructor * Allow includer to specify in advance the value for JSON_HAS_RVALUE_REFERENCES
3d5f5c9
to
2b00891
Compare
Ok, I'd be fine with merging this, if there are no objections. I'll wait a couple days... |
Looks good. I do wish we could have the move assignment operations. |
Soon. The old branches are stable enough that we can soon consider |
JSON_HAS_RVALUE_REFERENCES
rebased #264.