| void print_struct(reflection T){
|
| for(field f in T.fields){
|
| printf("type=%s value=%s field_offset=%zu\n", f.type.name, f.name, f.offset);
|
| }
|
| }
|
|
|
| int main(){
|
| print_struct(reflect(struct mystruct));
|
| }
|
| template print_value(type T, char* name){
|
| void id(concat_constexpr("print_", name)) (T value){
|
| switch(reflect(T)){
|
| case reflect(int): printf("%d\n", value); break;
|
| case reflect(float): printf("%f\n", value); break;
|
| default:
|
| if(reflect(T).ispointer)
|
| printf("%p\n", value);
|
| break;
|
| }
|
| }
|
| }
|
|
|
| print_value(int, "int");
|
|
|
| int main(){
|
| print_int(123);
|
| }
|
| int numbers[] = {
|
| -1,
|
| for(int i=0; i<100; i++){
|
| yield i*2;
|
| },
|
| 666
|
| };
|
|
|
| for(int i=0; i<102; i++){
|
| if(i % 2){
|
| void id(concat_constexpr("print_num_", tostring_constexpr(i))) (void){
|
| printf("%d", numbers[i]);
|
| }
|
| }
|
| }
|
|
|
| int main(){
|
| print_num_5();
|
| }
|