Add experimental C++26 reflection ORM#2545
Draft
1ukidev wants to merge 2 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR aims to implement a new way of using the ORM (
orm::ReflectiveMapper) through the compile-time reflection introduced in C++26. I have been working on this feature for personal use for some time, and I thought it would be interesting to share it here. I am not sure how open the project is to adopting newer C++ standards.Thanks to reflection annotations, it is currently possible to write code such as:
All metadata is generated statically at compile time, including the query strings used for retrieval, insertion, counting, updating, and deletion. This practically eliminates the need for utilities such as
drogon_ctl.The workflow with
orm::ReflectiveMapperis as simple as:A example is available in
examples/orm_reflection/main.cc. For now, only synchronous and callback-based database communication is supported, but other approaches can be discussed in the future.Currently, only GCC 16 provides official experimental support for reflection, which may require additional caution when using it in production. I'm marking this as a draft for now. Feel free to ask if you have any questions.