Created
April 10, 2014 13:35
-
-
Save usagi/10382979 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 <memory> | |
| #include <iostream> | |
| template<class T> using S = std::enable_shared_from_this<T>; | |
| struct A: S<A> { auto fa() const -> void { std::cerr << this << "\n";} }; | |
| struct B: S<B>, A { auto fb() const -> void { std::cerr << this << "\n";} }; | |
| auto main() -> int | |
| { | |
| auto p = std::make_shared<B>(); | |
| p -> fa(); | |
| p -> fb(); | |
| std::cerr << p << "\n"; | |
| } |
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
| 0x8376a8 | |
| 0x837698 | |
| 0x837698 |
usagi
commented
Apr 10, 2014
Author
- http://stackoverflow.com/questions/22988709/why-different-this-address-in-using-inherited-the-stdenable-shared-from-this
- http://blog.wonderrabbitproject.net/2014/04/stackoverflow-stdenablesharedfromthisaa.html
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment