parallel101 / stl1weekend

Build your own STL in one weekend
166 stars 13 forks source link

Enable shared from this for constructor as well #8

Open winner245 opened 1 day ago

winner245 commented 1 day ago

enable_shared_from_this should also work for shared_ptr objects created by constructors.

winner245 commented 12 hours ago

Please review the PR. Without this PR, the following code would not run:

SharedPtr p0(new StudentDerived("彭于斌", 23)); p0->func(); Student* mqb = new Student("mq白", 19); p0.reset(mqb); p0->func();