I want to make a logging function for member variables by using
reflection.
import std.stdio;
class D : B
{
override void foo() {
a = 4.0;
b = 3.0;
}
double a;
double b;
}
class B
{
void Log()
{
auto a = [__traits(derivedMembers, D)];
foreach(memberName; a) {
// Somehow write only member variables with their
names
// Result should be : a = 4.0, b = 3.0
}
}
void foo()
{
}
}
void main()
{
auto b = new D;
b.Log();
}
As I wrote in the comments I want to see member variable's name
and its value.
What is the best way to achieve that?
Erdem