Skip to content

C++26 static reflection #2282

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

Open
wants to merge 82 commits into
base: master
Choose a base branch
from
Open

C++26 static reflection #2282

wants to merge 82 commits into from

Conversation

lemire
Copy link
Member

@lemire lemire commented Oct 29, 2024

Building our way up, this would add support for building JSON strings/documents using simdjson.

The end goal is to do:

kid k{12, "John", {"car", "ball"}};
simdjson::to_json(k);
// would generate {"age": 12, "name": "John", "toys": ["car", "ball"]}

We also add static-reflection support for deserialization so that you can do...

kid k = doc.get<kid>();

This works now, with a user-provided class.

See: Reflection-based JSON in C++ at Gigabytes per Second

With a version of LLVM supporting static reflection, the following might work:

CXX=clang++ cmake -B buildreflect -D SIMDJSON_STATIC_REFLECTION=ON  -DSIMDJSON_DEVELOPER_MODE=ON
cmake --build buildreflect --target static_reflection_builder_tests --verbose && ./buildreflect/tests/builder/static_reflection_builder_tests

We still need:

  • documentation (we need to create a new file build.md where we document the building)
  • benchmarks
  • more tests

Fixes: #1386

@lemire lemire added the enhancement New feature or request label Oct 29, 2024
@FranciscoThiesen
Copy link
Member

Merged with master since this branch is somewhat outdated now. Will resume working on it to fix the failing tests.

lemire and others added 18 commits March 23, 2025 16:32
* The syntax changed: ^E became ^^E.

* guarding

---------

Co-authored-by: Daniel Lemire <dlemire@lemire.me>
Haven't been able to validate this locally for now, as the reflection branch that I am building clang from doesn't have the new ^^ operator.
…static reflection (#2358)

* adding docker config and instructions so that our users can test the
static reflection

* completing the instructions

* pruning white spaces

---------

Co-authored-by: Daniel Lemire <dlemire@lemire.me>
@lemire lemire marked this pull request as ready for review April 14, 2025 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSON builder
2 participants