An abstract data type that simulates a pointer while providing additional features, such as automatic garbage collection or bounds-checking.

learn more… | top users | synonyms

4
votes
1answer
57 views

Builder/named argument/fluent interface pattern with unique_ptr

I'm trying to figure out the cleanest way to implement a fluent interface with unique_ptr and other "modern" C++ language constructs. Here's my first attempt: ...
4
votes
0answers
96 views

Is this pass-by-reference of a shared_ptr correct?

I'm writing a scene graph library in C++ and I'm currently designing the parent-child relations. I decided to use shared pointers for parent-to-child-relations and weak pointers for child-to-parent ...
3
votes
1answer
86 views

Auto-recycling C++11 polymorphic smart pointers

I've recently read an interesting blog post by Philipp Zschoche: it explains how it's possible to avoid unnecessary allocations/deallocations by keeping track of previously allocated memory in a ...
3
votes
2answers
192 views

Binary Tree with C++11 smart pointers

I'm trying to replace the use of raw pointers with smart pointers in my C++ code. The following bit is from my first attempt at a self-balancing binary tree, though there is nothing self-balancing at ...
0
votes
1answer
84 views

One more shared pointer

Here's a (hopefully) better shared pointer than the previous one. The improvement is that now it should also accept function and lambda objects. Should work fine with threads. ...
3
votes
0answers
111 views

Smart pointer memory pool

I'm using a third-party library which utilizes boost::shared_ptr for memory management. The problem is that I need to allocate many objects and I have detected ...
5
votes
2answers
221 views

Proposed solution to dangling pointers: a non-owning smart pointer

The lifetimes of various objects referring to each other are sometimes only known at runtime. For example, in a side scrolling shooter game, a HomingMissile ...
1
vote
2answers
133 views

Smart pointer implementation

I've decided to implement a simple smart pointer: ...
3
votes
3answers
1k views

Singly linked-list with smart pointers

A few things: I tried to do it with smart pointers because I wanted to learn about them. I'm not sure I made the right choice of type, however (and started to regret it half-way through). This is ...
3
votes
0answers
245 views

yet another shared pointer

What might be wrong with this shared pointer? One good point of it might be, that it should handle array types correctly by default (e.g. ...
10
votes
2answers
410 views

make_auto implementation for C++03 compilers

I want to provide, in the the spirit of C++11/boost make_shared and C++14 make_unique, a production-ready make_auto for C++03 compilers. So, inspired boost's make_shared implementation for C++03 ...
4
votes
1answer
2k views

efficient smart pointer implementation in C++

So the idea behind this is mainly educational but I might even consider using it in reality if turns out to be good. Here's my first try at implementing ...
3
votes
4answers
194 views

Request for review: reference counting smart pointer

I made a reference counting smart pointer class. My aim is to make a "minimal" but "general purpose" smart pointer class with proper documentation. This is basically for educational purpose. Please ...
7
votes
2answers
156 views

Am I using copy ctors/move ctors/shared_ptr correctly?

Here is my simple example: there is a class A with few primitive members and a class B with few primitive members but also a collection of objects of type A. This is my A class: ...
5
votes
1answer
309 views

A pointer vector sorted by its member function

I'm asking for suggestions on a random accessed vector with allocated elements sorted by its key obtained from its member function. I use it with Qt tree view where the access, add and deletion of ...
1
vote
1answer
772 views

Shared Pointer implementation

Before you say anything: Due to project constraints, we cannot use Boost and we cannot use C++11 (yet; perhaps this will change some day). The fact that I was unable to use smart pointers was nagging ...
11
votes
3answers
2k views

scoped_ptr for C++/CLI (ensure managed object properly frees owned native object)

Motivating SO question: Is there a C++/CLI smart pointer project (e.g. scoped_ptr)? I'm interested in any reviewer comments, and especially identified bugs or inconsistencies with the native ...