#include <memory>

struct B : public std::enable_shared_from_this<B> {
};

struct A : public std::enable_shared_from_this<A> {
    A()
        : b_()
    {}

    std::shared_ptr<B> b_;
    void SomeFunction();
};

void A::SomeFunction() {
    auto a_copy = shared_from_this();
}

int main()
{
    A a;
    a.SomeFunction();
}
