Skip to content

Iterator pointer semantics fix#18

Open
duckie wants to merge 1 commit intovivkin:masterfrom
duckie:iterator_pointer_semantics_fix
Open

Iterator pointer semantics fix#18
duckie wants to merge 1 commit intovivkin:masterfrom
duckie:iterator_pointer_semantics_fix

Conversation

@duckie
Copy link
Copy Markdown

@duckie duckie commented Jul 20, 2015

Hello good sir

While writing a wrapper around gason for my company, I ran into a small problem. Here is a fix proposal.

API breakage here, but original API is erroneous.

The JsonIterator::operator* in gason does not implement correctly the pointer semantics. An iterator should be used in those ways (assuming v is a value containing an object).

for(auto it = begin(v); it != end(v); ++it)
  cout << it->key << endl;
for(auto node : v)
  cout << node.key << endl;

But in gason is used like this:

for(auto node : v)
  cout << node->key << endl;

This is not consistent with common behaviors of C++ iterators. This patch fixes it.

@ChrisJefferson
Copy link
Copy Markdown
Contributor

While I actually agree with this patch in principle, I would hope it would wait until a major release, as it's going to break every piece of code using gason!

@duckie
Copy link
Copy Markdown
Author

duckie commented Jul 21, 2015

Yes it does. There is no problem into delaying it for a major release. Do you plan one ? Do you want me to request the pull into a release candidate branch ?

@ChrisJefferson
Copy link
Copy Markdown
Contributor

Just to say, I'm just a random guy who read and commented on your patch, not @vivkin :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants