Last active
March 24, 2020 00:50
-
-
Save uhziel/5a48796faf1532c03c2105ad10bf6043 to your computer and use it in GitHub Desktop.
g++ -g -std=c++11 -o cpp-traverse-example cpp-traverse-example.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "traverse.h" | |
struct Point { | |
int32_t x; | |
int32_t y; | |
}; | |
TRAVERSE_STRUCT(Point, FIELD(x) FIELD(y)) | |
/* Expand to | |
* void visit(traverse::CoutWriter& visitor, Point& obj) { | |
* visit_struct("Point", visitor) | |
* .field("x", obj.x) | |
* .field("y", obj.y); | |
* } | |
*/ | |
int main() { | |
Point point; | |
point.x = 1; | |
point.y = 2; | |
traverse::CoutWriter writer; | |
visit(writer, point); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment