12 questions
3
votes
1
answer
141
views
Extracting member function traits with C++26 reflection
Background info: I am trying to write a source code (i.e., plain text) generation tool which generates a stub implementation of an abstract base class. This looks something like
namespace acme {
...
11
votes
1
answer
1k
views
Is there any way to iterate data members with STL algorithms using the C++26 reflection?
With C++26 reflection, we can simply iterate all data members of an object:
#include <iostream>
#include <meta>
struct Foo {
int x;
int y;
};
void PrintFoo(const Foo& foo) {
...
1
vote
1
answer
477
views
Static reflection for Protobuf in C++
This is a bit of a "moon shot", but still: does the C++ Protobuf implementation support "static reflection"; or is there a way to make this work?
My goal is to have an API e.g. ...
2
votes
2
answers
462
views
Can I cast a number into an enum, safely, with a fallback value?
I would like to write something like:
template <typename E, E fallback>
E safe_cast_to_enum(std::underlying_type_t<E> e);
which, for an enum class (or just an enum?) E, casts e to a ...
12
votes
1
answer
8k
views
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 ...
6
votes
2
answers
281
views
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++. ...
4
votes
1
answer
495
views
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.
...
1
vote
0
answers
2k
views
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. ...
1
vote
1
answer
212
views
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 ...
3
votes
2
answers
292
views
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)
{
...
6
votes
1
answer
161
views
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?
2
votes
3
answers
892
views
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 ...