Skip to main content
Stack Overflow
  1. About
  2. For Teams
Filter by
Sorted by
Tagged with
Best practices
0 votes
2 replies
91 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 ...
4 votes
1 answer
147 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 ...
-3 votes
1 answer
135 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 ...
0 votes
1 answer
193 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 ...
1 vote
1 answer
153 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; ...
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 ...
5 votes
0 answers
252 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::...
-1 votes
2 answers
325 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 ...
2 votes
4 answers
319 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->...
1 vote
2 answers
102 views

#include <cstddef> #include <stdexcept> #include <cassert> template <typename T> class Pointer { private: std::ptrdiff_t offset; std::ptrdiff_t calculateOffset(const ...
3 votes
1 answer
127 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&...
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 ...
1 vote
1 answer
154 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 ...
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 ...
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 ...

15 30 50 per page
1
2 3 4 5
...
192

AltStyle によって変換されたページ (->オリジナル) /