Last active
August 29, 2015 13:59
-
-
Save usagi/10733058 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <cassert> | |
| #include <boost/property_tree/ptree.hpp> | |
| int main() | |
| { | |
| using namespace boost::property_tree; | |
| ptree pt; | |
| int x = 123; | |
| class Y { } y; | |
| pt.put("x.ptr", &x); | |
| pt.put("y.ptr", &y); | |
| auto px = static_cast<decltype(x)*>(pt.get<void*>("x.ptr")); | |
| auto py = static_cast<decltype(y)*>(pt.get<void*>("y.ptr")); | |
| std::cout | |
| << px << " " << typeid(px).name() << "\n" | |
| << &x << " " << typeid(&x).name() << "\n" | |
| << py << " " << typeid(py).name() << "\n" | |
| << &y << " " << typeid(&y).name() << "\n" | |
| ; | |
| assert(px == &x); | |
| assert(py == &y); | |
| } |
This file contains hidden or 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
| 0x7fffd9d47604 Pi | |
| 0x7fffd9d47604 Pi | |
| 0x7fffd9d47600 PZ4mainE1Y | |
| 0x7fffd9d47600 PZ4mainE1Y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment