Nested struct or something else?

That won’t affect performance. It might be useful to debug the code.

Concerning the general question, maybe this thread helps, particularly what I have marked as a solution to it, which is the possibility of writing function-like objects. The types of structures of objects and functions to achieve what you want are all there, I think: Define data-dependent function, various ways

2 Likes