Get attribute by name

后端 未结 5 2014
野的像风
野的像风 2020-11-30 13:15

I have a struct definition with about 25 elements

struct X { field 1; field 2; .. };    

and I\'m trying to fill it with some map values <

5条回答
  •  孤独总比滥情好
    2020-11-30 13:46

    It's not really possible to do that; the information you need is no longer present at runtime. You might be able to do something with a map and some pointers, but to be honest you would probably be better off just wrapping it up in a function that takes a map and puts the values into the appropriate fields.

提交回复
热议问题