Skip to content

Instantly share code, notes, and snippets.

@usagi
Created April 10, 2014 13:35
Show Gist options
  • Select an option

  • Save usagi/10382979 to your computer and use it in GitHub Desktop.

Select an option

Save usagi/10382979 to your computer and use it in GitHub Desktop.
#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";
}
0x8376a8
0x837698
0x837698