←back to thread

196 points svlasov | 1 comments | | HN request time: 0.283s | source
Show context
stefanos82 ◴[] No.40851614[source]
Can I ask a naive question that consists of two parts and please don't flame me? lol

  * What type of problems static reflection could solve, in general?
  * Are there specific cases and / or situations where static reflection could resolve such case, even simplify an unnecessary complexity?
replies(8): >>40851661 #>>40851675 #>>40851709 #>>40851795 #>>40851942 #>>40852552 #>>40853159 #>>40853615 #
quotemstr ◴[] No.40851675[source]
> What type of problems static reflection could solve, in general?

Imagine making a plain

    struct Point { float x; float y; };
and wanting to serialize it to JSON without further ceremony
replies(2): >>40851792 #>>40853917 #
throwway120385 ◴[] No.40851792[source]
This is the thing that's driving me away from C++ very quickly. A big part of our code base is code that handles this, and it either has to be in a DSL and constantly recompiled or we have to make a bunch of boilerplate. It's a huge problem for the language not to be able to do this.
replies(3): >>40852051 #>>40852750 #>>40853258 #
germandiago ◴[] No.40853258[source]
I suggest you to take a look at Boost.Describe.

I have a scripting layer in a game that needs to set properties in a C++ Model. I used a single Boost.Describe macro per struct and a generic get/set property. It worked very well and made me get rid of a lot of boilerplate.

https://www.boost.org/doc/libs/develop/libs/describe/doc/htm...

replies(2): >>40853792 #>>40857633 #
1. throwway120385 ◴[] No.40857633[source]
Yeah, that looks like it would do what I need.