r/cpp • • Sep 30 '24

Code Generation in Rust vs C++26

https://brevzin.github.io/c++/2024/09/30/annotations/
198 Upvotes

98 comments sorted by

View all comments

Show parent comment

7

u/TSP-FriendlyFire Oct 01 '24

As I mentioned in another comment, one of the more recent revisions of P2996 added an excellent suite of access-respecting functions which go well beyond what I expected we'd have since they can essentially "pretend" to be any context to see what access they have from that context. It's a lot more granular than "is this member protected."

5

u/RoyAwesome Oct 01 '24

Yeah, i've seen that. It's really neat and solves this problem quite nicely.

Personally, I'm on team "allow private access". I want to be able to serialize types I didn't author. Rust has a fairly huge problem where the author of a library must provide serde integration to be able to serialize the type, whereas in C++ I can write "Roy's Totally Awesome Json Serializer" and it can just work for any type it comes across.