simdjson/singleheader
Joe Jevnik d2bea0c228
Add support for C++ 20 ranges. (#1050)
C++ 20 adds a new feature called "ranges", which provides components for dealing
with sequences of values: https://en.cppreference.com/w/cpp/ranges.

A range is like a normal object containing `begin` and `end`, except there are
also composable operations like maps, filters, joins, etc.
The iterator objects returned by a range's `begin` and `end` require a more
strict set of operations than is needed for a range-for loop.

This PR adds the extra operations needed to support turning `dom::array` and
`dom::object` into a range.
This PR does not depend on any C++ 20 behavior, the added operators are all
valid C++ 11, and are already part of the LegacyIterator concepts.
This PR adds extra code behind: `#if defined(__cpp_lib_ranges)` guards, which is
the new C++ 20 specified feature test macro for ranges support. When ranges
support is detected, extra compile time checks are added to ensure that
`dom::array` and `dom::object` satisfy the range concept. No runtime tests have
been added yet because these compile time checks should be sufficient.

If desired, the `static_assert` code could be moved out of the actual code
headers and put into a test file.
2020-07-21 13:27:39 -04:00
..
CMakeLists.txt Mingw tests (32-bit and 64-bit) (#1004) 2020-06-29 21:10:54 -04:00
README.md Put back the amalgamation files and add tests (#929) 2020-06-12 17:57:45 -04:00
amalgamate.sh Nitpicking. 2020-06-23 22:07:40 -04:00
amalgamate_demo.cpp Add support for C++ 20 ranges. (#1050) 2020-07-21 13:27:39 -04:00
simdjson.cpp Add support for C++ 20 ranges. (#1050) 2020-07-21 13:27:39 -04:00
simdjson.h Add support for C++ 20 ranges. (#1050) 2020-07-21 13:27:39 -04:00

README.md

Try : c++ -O3 -std=c++17 -pthread -o amalgamate_demo amalgamate_demo.cpp && ./amalgamate_demo ../jsonexamples/twitter.json ../jsonexamples/amazon_cellphones.ndjson