Hey, I have just been studying how to implement reflection in the simplest and least expensive way possible in c++.
I've been studying up on macros, since those are all pre-processor, but I can't seem to find a way to accomplish what I am trying to do.
Sorry if this sounds kinda stupid. I am just sorta learning this stuff. I want to write a macro function that takes a string literal (for a variable or function name), and put it in a vector. The only problem is, I don't know how to create a vector in the preprocessing stage.
I was wondering if it is possible to create some sort of 'macro class' or struct to store this data, so that I can use this for later.
For example, I want to do something like this:
Psuedo-code:
#include <iostream>
#include <string>
#include <vector>
#define struct ReflectionData /
{/
std::vector<string> names;/
}
#define ADD_REFLECTION_DATA(std::string data) (ReflectionData.names.push_back(data))
ADD_REFLECTION_DATA("mario")
ADD_REFLECTION_DATA("luigi")
int main()
{
std::cout << ReflectionData.names[0];
std::cout << ReflectionData.names[1];
std::cout << ReflectionData.names[2];
return 0;
}
ADD_REFLECTION_DATA("Bowser")
Output:
Mario
Luigi
Bowser
Any idea how to accomplish something like this?