Upfront disclosure: I think the entire thing is nonsense and "works" by chance, but I found this code and it seems to "work" for low-enough values of ...
Upfront disclosure: I think the entire thing is nonsense and "works" by chance, but I found this code and it seems to "work" for low-enough values of ...
Note: Before posting the question, I have gone through the existing questions on std::bad_weak_error while using shared_from_this to pass the shared_p ...
From theory, one difference between make_shared() and shared_ptr is the memory allocation technique. make_shared() should use a single block, while sh ...
I have a class variable ptr, I want it to point to the first element of my 1D int array. What is the difference between these two statements, and whi ...
I have the following piece of code: #include <memory> class A: public std::enable_shared_from_this<A> {}; struct B: public A, public st ...
I have two classes, Server and Client, each with their own mock class and has a getClients and getServer method respectively (the actual classes are m ...
I have a smart pointer defined like this and another array I want to copy data in arr to ptr, I tried using this But when I try printing like ...
I'm fairly new to smart pointers and I couldn't understand the result of the code I attached below. Basically the reference count and the raw pointer ...
I'm learning the Gandiva module in Apache Arrow. I found that many APIs require parameters in the form of std::shared_ptr<T>*, eg here is an typ ...
Given the following code: Will all members of the Container shared_ptr instance be stored on Heap, including all instances of the Element class ins ...
I am trying to create and use a std::shared_ptr within a class function whose constructor takes in a std::shared_ptr private data member (of the same ...
I keep getting heap use after a free error when I try to pass a shared pointer to a class object. Firstly, my tree builder has the root as a private ...
Hey so I'm writing a function that will return the correct class if the name is found. In the case that I don't find a class what and how should I ret ...
Node.h doubleLinkedList.h Node.cpp doubleLinkedList.cpp main.cpp The error I'm getting is: unhandled exception thrown: read access vio ...
I have a map of objects where keys are std::string. How can I generate a vector of keys without copying the data? Do I need to change my map to use s ...
I'm trying to pass a shared_ptr to an object around, which may or may not be null: #include <iostream> #include <memory> struct MyObject ...
I'm building an asynchronous program where the boost::asio::io_context has a shared pointer to my object. When my object stops posting asynchronous wo ...
I would like an elegant way to safely read data in a field which is wrapped in "nullable types" such as std::optional and std::shared_ptr. Take as exa ...
Let's consider code below: The result is surprising me because condition1 is false but condition2 is true. Why? Can you explain what is going on he ...
EDIT: I've changed this to use std::shared_ptr in both containers and also specified a virtual destructor for the base class. It still crashes the ins ...