Skip to main content
Best practices
0 votes
2 replies
92 views

I'm trying to make a struct that has dynamic methods by storing FnMuts in the struct. The FnMuts would be a function written in a scripting language like Python or Lua, but there might be some cases ...
Choosechee's user avatar
4 votes
1 answer
158 views

As I understand it, std::polymorphic<T> and std::indirect<T> are const-propagating wrapper types for an owning pointer to a T object, where the target of the pointer is copied with the ...
dumbass's user avatar
  • 27.3k
-3 votes
1 answer
137 views

I am trying to create Linkedlist, where array is passed, and linkedlist is returned. However, there seems something wrong, and the linkedlist returned is circular. /** * Shared pointer, pass vector ...
Susobhan Das's user avatar
  • 1,309
0 votes
1 answer
206 views

How does the implementation of C++ std::weak_ptr upgrade to std::shared_ptr and access the object without risking a use-after-free? The scenario: In a concurrent setting, you have a weak pointer to an ...
Qwert Yuiop's user avatar
1 vote
1 answer
156 views

Hope this message finds you well. I'm a little bit lost while using trompeloeil expectations syntax. Let's say I have this: #include <memory> class IA { public: virtual ~IA() = default; ...
anthonyNk's user avatar
3 votes
1 answer
181 views

I'm attempting to make a game in C++ where pieces will move around a gameboard. In our team, we're trying to be good and use as much modern methodology as we can, given we've gotten rusty and now have ...
Force Gaia's user avatar
5 votes
0 answers
254 views

In this earlier SO question: What is a smart pointer and when should I use one? Ten years ago, I gave a relative simple answer and got a bunch of upvotes. One paragraph in my answer reads: Use std::...
einpoklum's user avatar
  • 138k
-1 votes
2 answers
331 views

Let's say you allocate an object and pass its address in a Windows message (posted, not sent). In the message handler, the address is recovered and used to initialize a std::unique_ptr. Will the ...
0___________'s user avatar
  • 71.8k
2 votes
4 answers
320 views

I have this existing working code, which I am trying to convert to implementation: Bitmap *pbitmap = new Bitmap(L"images.png"); nWidth = pbitmap->GetWidth(); nHeight = pbitmap->...
Gorlash's user avatar
  • 81
1 vote
2 answers
103 views

#include <cstddef> #include <stdexcept> #include <cassert> template <typename T> class Pointer { private: std::ptrdiff_t offset; std::ptrdiff_t calculateOffset(const ...
Tejas Sharma's user avatar
3 votes
1 answer
130 views

I have the following minimal reproducible example where it seems that my unique-pointer-containing object B is not allowed to contain a unique pointer to another instance of B: #include <iostream&...
Featherball's user avatar
1 vote
0 answers
47 views

Intrusive shared pointers have some advantages over classical control block shared pointers, as they allow, as far as I understand, atomic, lock-free concurrent operations with single writer and ...
galinette's user avatar
  • 9,420
1 vote
1 answer
155 views

I wrote a toy raytracer following the popular raytracing in one weekend series that uses heavily shared_ptr for more or less everything. The codebase in nice and tidy but extremely slow (a 400x400 ...
Niccolò Tiezzi's user avatar
3 votes
1 answer
141 views

I am writing a UI framework for a microcontroller, in which I want to do a hierarchical menu system. For that in particular I have the following classes: class MenuNode { public: MenuNode(const ...
akasaka's user avatar
  • 322
2 votes
1 answer
154 views

I was experimenting with std::unique_ptr and reference-type deleters, and noticed that it does not allow polymorphic conversion when moving a unique_ptr with a derived-class deleter into one expecting ...
yqZhang4480's user avatar

15 30 50 per page
1
2 3 4 5
192