enable-shared-from-this Questions

3

Solved

I have two classes A and B, where B is a subclass of A. I need both classes to use std::enable_shared_from_this. I tried this: #include <memory> #include <iostream> #include <vecto...

2

I'm learning smart pointers and shared_from_this. In Class Inheritance Relations, it will be very hard to understand. I have two base classes CA and CB, they are derived from enable_shared_from_th...
Triplenerved asked 31/8, 2019 at 13:23

3

Solved

My class inherits from multiple bases, one of which is std::enable_shared_from_this. Must it be the first base? Suppose the following example code: struct A { ~A(); }; struct B { ~B(); }; struct ...

2

Solved

I'm having trouble using shared_ptr and weak_ptr along with enable_shared_from_this. When I google the symptoms of what I'm seeing, everybody suggests "you cannot use shared_from_this() when there...

3

Solved

I have an object (Z) which derives from two other objects (A and B). A and B both derive from enable_shared_from_this<>, respectively enable_shared_from_this<A> and enable_shared_from_...

4

Solved

I was playing around for a bit using the shared_ptr's and enable_shared_from_this, while I run into something I don't really understand. In my first attempt I constructed something like this: cla...

2

Given this class which is enable_shared_from_this: class connection : public std::enable_shared_from_this<connection> { //... }; Suppose I create two instances of std::shared_ptr from the...

3

Solved

I just knew std::enable_shared_from_this form this link. But after reading the code below, I don't know when to use it. try { Good not_so_good; std::shared_ptr<Good> gp1 = not_so_good.getp...

1

Solved

BI am using enable_shared_from_this in my code, and I am not sure if its usage is correct. This is the code: class A: public std::enable_shared_from_this<A> { public: void foo1() { auto p...

3

I am currently having some troubles when using boost enable_shared_from_this and multiple inheritance. The scenario can be described as follows: Class A implements some functionality and should ...
Indenture asked 18/2, 2013 at 14:59

2

Solved

I have a base class which derives from boost::enable_shared_from_this, and then another class which derives from both the base class and boost::enable_shared_from_this: #include <boost/enable_s...

3

Solved

The enable_shared_from_this helper contains a weak pointer that is set when creating shared pointer to the object. That means there is the reference-count (allocated separately or together with the...
Prepositor asked 26/7, 2011 at 7:58
1

© 2022 - 2025 — McMap. All rights reserved.