Questions tagged [static-reflection]

8 questions
6
votes
2 answers

C++: Is there any bijective mapping between types and any other data type defined by the standard?

I am working on a project that makes heavy use of static polymorphism. A particular use-case that I am interested in would be made possible by static reflection, but we still don't have this in C++. The use case looks something like this: I have a…
wvn
  • 624
  • 5
  • 12
6
votes
1 answer

Can you make Asp.net MVC View wireup compile time safe?

Take the standard return statement for a controller: return View("Index"); is there a way to make this thing compile time safe? using static reflection or some other trick?
Maslow
  • 18,464
  • 20
  • 106
  • 193
4
votes
0 answers

What syntax is expected in C++26 for static reflection?

As far as I know, static reflection is currently on the roadmap for C++26. The reflection TS proposes a type-based syntax, but a value-based syntax has also been proposed in the meantime. In P2560 Matúš Chochlı́k presented a comparison of the both…
Benjamin Buch
  • 4,752
  • 7
  • 28
  • 51
4
votes
1 answer

Do we need metaclasses to do this, or is reflection enough?

So I have been quite looking forward to metaclasses. I then heard that it won't be in c++23, as they think we first need reflection and reification in the language before we should add metaclasses. Looking over c++23 reflection, there appears to be…
Yakk - Adam Nevraumont
  • 262,606
  • 27
  • 330
  • 524
3
votes
2 answers

What are the use cases for this static reflection code?

This is Oliver Hanappi's static reflection code he posted on stackoverflow private static string GetMemberName(Expression expression) { switch (expression.NodeType) { case ExpressionType.MemberAccess: …
Maslow
  • 18,464
  • 20
  • 106
  • 193
2
votes
3 answers

On-the-fly fields from Static Reflection?

I've been studying up on static reflection with LINQ expressions - very cool! One thought I had - is it possible for one class to 'generate' fields on one class based on static reflection done on another class? I'm thinking specifically of the…
n8wrl
  • 19,439
  • 4
  • 63
  • 103
1
vote
0 answers

Is it possible for Rust to iterate over all the types in a module?

I have trait like this to describe the structure of a type, if I know the type at compile-time, of course I can inspect all the associate constants, associate types, and static member functions of it. But the point is, there're hundreds(or even more…
1
vote
1 answer

C# Binding data objects

I need binding between two similar objects (C#): public class TypeA { public int I; public string S; } public class TypeB { public IntField I; public StringField S; } When a field in TypeA changes I need to update the matching…
Tom
  • 964
  • 9
  • 25