-
Couldn't load subscription status.
- Fork 472
Fix/reorganize to/fromJSON code #5403
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
base: main
Are you sure you want to change the base?
Conversation
ChrisDodd
commented
Oct 21, 2025
- fix UnparsedConstant handling
- clean up corner cases of fromJSON
| std::enable_if_t<has_fromJSON<T>::value && !std::is_base_of_v<IR::INode, T> && | ||
| std::is_pointer_v<decltype(T::fromJSON(std::declval<JSONLoader &>()))>> | ||
| unpack_json(T &v) { | ||
| v = *(T::fromJSON(*this)); |
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.
Does it make sense to force move semantics here?
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.
You already get move semantics, as T::fromJSON returns a type T xvalue. That's actually how calling std::move forces move semantics -- std::move is just a function that returns a type T xvalue. There's nothing special about it.
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.
I was under impression that T::fromJSON returns a pointer – T*, no? So v = *(T::fromJSON(*this)) would incur a copy.
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.
It can either return a T or a T *. If it is a T * then it might not be safe to move?
4d123ef to
46fb2fd
Compare
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.
Trading a review for a review on #5063
- fix UnparsedConstant handling - clean up corner cases of fromJSON Signed-off-by: Chris Dodd <[email protected]>
46fb2fd to
a2f6523
Compare