11 questions
8
votes
1
answer
848
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) {
...
2
votes
2
answers
419
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 ...
6
votes
2
answers
272
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++. ...
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. ...
3
votes
2
answers
290
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)
{
...
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 ...