Comment

Comment by whizzter

Oh my, here I'm looking like a fool, literally gave a talk on the new <meta>/Reflection feature on Thursday and doing it assumed that it was more or less a lock (Well I guess the refl feature will come out if contracts can be dumped and the standard gets out even if it won't technically be in C++26 anymore :P )

The reflection feature is good, I would've settled for less but there's some pretty cool stuff enabled by it.

- direct to struct JSON parsing with property-name aliasing via annotations

- field creation/renaming, I've made a make_named<"a","b">(1,"hello") to create an object with fields named a and b (think of std::make_tuple on steroids)

- I'm basically halfway done with a DB abstraction that can be used similarly to C#'s Linq.

struct [[=sql26::name("posts")]] post { int id; std::string name; };

dbcontext<post> dbctx;

for(auto post:dbctx.posts.where([](auto post) { return post.id>100; }) { ... }

^- in the above example the template inclusion of post creates the posts-field in the context, the where predicate lambda gets a decorated variant of the post type members that are then deferred until execution (starting iterating the itererable).

It's dangerously powerful though since all of this is enabled by consteval, so any IDE support will need to be running the consteval code continiously in these scenarios to update type-info before being able to do code completion (even if people are probably way into LLM's to bother anymore?).

The talk isn't online yet since they haven't had time to edit the videos.

The JSON and make_named example/code can be found in my repo, haven't pushed the SQL feature yet as I'm not happy with some other parts of the API surface yet (aggregation is hard to express/translate compactly and unambigiously).

https://github.com/whizzter/ret26

parent whizzter 6 days ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton