Add support for C++11 range-based for-loop #21

Merged
merged 2 commits into from May 22, 2013

Projects

None yet

2 participants

@LB--
LB-- commented Mar 27, 2013

I added support for C++11 range-based for-loops:

   for(auto &o : my_json_value->u.object)
   {
      std::cout << o.name << std::endl;
   }

Similar for arrays. No type checking, unfortunately - I couldn't manage that.
Technically if the begin and end functions were compatible with C++03 then the STL algorithms could be used on them with C++03 compilers, but that's for another day - they're only compatible with C++11, which is why the check for __cplusplus >= 201103L is in there. I tested with clang++ -std=c++11 and tried to follow the same conding style as you. (Edit: just fixed a minor indentation mistake)

Fixes #14

LB-- added some commits Mar 27, 2013
@LB-- LB-- Add support for C++11 range-based for-loop
for(auto &o : my_json_value->u.object)
{
std::cout << o.name << std::endl;
}
And similar for arrays. No type checking, unfortunately - I couldn't
manage that.

Fix indentation
b445038
@LB-- LB-- Merge pull request #1 from udp/master
Merge upstream changes
83fd768
@udp
Owner
udp commented May 22, 2013

Thanks Nicholas, looks good to me.

@udp udp merged commit daf2065 into udp:master May 22, 2013

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment