Skip to main content

All Questions

Tagged with
2 votes
1 answer
99 views

Decoupling receiving data and processing data by passing callback and shared_ptr

Sorry for my poor English. I want to decouple receiving data and processing data, this is the demo code: ...
John's user avatar
  • 459
6 votes
3 answers
6k views

dynamic_pointer_cast for std::unique_ptr

dynamic_pointer_cast is only implemented for std::shared_ptr. I need the same functionality for unique pointers. The wrinkle is ...
Diederick C. Niehorster's user avatar
6 votes
2 answers
2k views

shared_ptr and make_shared implementations (for learning)

Recently, I've been going through Scott Meyer's Effective Modern C++ and found the discussion on shared_ptr really interesting. I also watched Louis Brandy's ...
eenz's user avatar
  • 123
1 vote
1 answer
434 views

Implementing a binary search tree using std::unique_ptr

I have implemented a binary search tree with 2 operations to begin with. I have tried to implement it using the best practices I could think of. Overall, I am happy with the implementation. But, I ...
Gaurav Sharma's user avatar
5 votes
3 answers
4k views

Implementing Sample Abstract Factory Pattern using Smart Pointers in C++

Was trying to implement and example code to smart pointer from link. Is it a good practice? To go with all unique pointers or should we use shared pointers in this case? How can i improve this ? <...
Kiran Thilak's user avatar
5 votes
0 answers
1k views

Polymorphic deleter for unique_ptr

There is a basic difference in the way C++ manages the deleter for std::unique_ptr and std::shared_ptr, mainly for allowing ...
Amir Kirsh's user avatar
3 votes
2 answers
640 views

Merge Sort C++11 C++17

Question Any way I can optimize this further using new C++11 or C++17 features? Would also like feedback on my variable naming, memory management, and style (notice my placement of ...
greg's user avatar
  • 1,017
6 votes
3 answers
5k views

Array Dynamic resize in heap

I have answered a Question in Stackoverflow link. a) Create a function called resize that can be used to increase the size of integer arrays dynamically. The function takes three parameters. ...
Kiran Thilak's user avatar
3 votes
2 answers
279 views

Mario Party Snake and Ladders Board

Context Was inspired from this LeetCode post to do my own System Design exercise of the common Snake and Ladders problem. As I was writing the code Mario Party kept coming to mind so I added a little ...
greg's user avatar
  • 1,017
5 votes
1 answer
1k views

C++ shared_ptr memory pool

I put together this little memory pool class to help avoid the costs associated with heap allocation and deallocation of objects that are frequently created & destroyed. It creates C++ standard <...
Thomas Johnson's user avatar
4 votes
2 answers
224 views

Simple device (fancy) pointer implementation

device_raw_ptr is a simple fancy pointer. It essentially wrap pointers to GPU memory. It's sole purpose is to separate out host pointers from device pointers, i.e. ...
Yashas's user avatar
  • 141
5 votes
3 answers
814 views

Stack Interview Code methods made from class Node and Smart Pointers

Mainly looking for feedback on my use of smart pointers to implement a standard stack. For interview level production code I have also include a namespace and asserts to test my class, let me know if ...
greg's user avatar
  • 1,017
5 votes
1 answer
155 views

wrapper for common subset of auto_ptr and unique_ptr API

I read an interesting old question on the Software Engineering SE about how to transition away from std::auto_ptr. So I wrote a wrapper around the common subset of <...
Greg Nisbet's user avatar
2 votes
1 answer
56 views

Queue Interview Code basic methods made from struct Node optimized

Using feedback from my previous implementation I'm writing a very simple Queue of struct Nodes with only these methods get_front(), get_back(), pop_front(), push_back(), and a ostream friend method. I ...
greg's user avatar
  • 1,017
1 vote
2 answers
154 views

shared_ptr basic implementation for non array types

This is an implementation to simulate the basic functionality of c++ shared_ptr. This doesn't provide features like custom deleter and make_shared(). I would really appreciate any feedback to improve ...
kapil's user avatar
  • 229
3 votes
3 answers
150 views

Linked List Interview Code methods, runtime, and edge cases refactored

In my previous post I had a number of steps given to me from the accepted answer on how I can write more production ready code. In this post I want this code to be reviewed as near production code I'd ...
greg's user avatar
  • 1,017
2 votes
3 answers
124 views

Queue Interview Code basic methods made from struct Node

Thanks for all the feedback, I optimized the code here. Here I'm Writing a very simple Queue of struct Nodes with only these methods get_front(), ...
greg's user avatar
  • 1,017
0 votes
2 answers
565 views

Binary Search Tree implementation with unique pointers

I have implemented a binary search tree using templates and unique_ptr in C++ 11. At present, only insertion and deletion are implemented. Please provide your feedback for improvements. ...
bornfree's user avatar
  • 229
10 votes
3 answers
9k views

Implementing a binary tree in C++ using "std::unique_ptr"

I have implemented a simple binary search tree class in C++ using std::unique_ptr objects to hold the pointers to each node. In doing this I have come across a ...
tjwrona's user avatar
  • 499
9 votes
3 answers
3k views

Binary Search Tree implementation using smart pointers

I have implemented below code for binary search tree implementation using shared pointer. At present, I have considered only integers. It supports insertion and deletion of values. Also, a print ...
bornfree's user avatar
  • 229
7 votes
1 answer
444 views

unique_ptr basic implementation for single objects

This is an implementation to simulate the basic functionality of unique_ptr. This doesn't provide features like custom deleter and ...
kapil's user avatar
  • 229
15 votes
2 answers
1k views

C++11 smart pointer 'library'

Edit: NOTE I'm a C++ "beginner" still in undergrad trying to teach myself modern C++ (because they don't do that in uni) so I'm sure this is riddled with errors that I am unaware of. Made a subset of ...
sjh919's user avatar
  • 153
4 votes
1 answer
293 views

value_ptr<T> - a C++11 header-only, deep-copying smart pointer that preserves value semantics for polymorphic and undefined types (updated)

My previous iteration was here. I've since finalized the concept as described in the title, and would appreciate any feedback GitHub Link Introduction: ...
Tom's user avatar
  • 417
2 votes
0 answers
319 views

Yet Another Non-Intrusive Reference Counted Smart Pointer Implementation

I needed a reference counted smart pointer for my project, and for some reason early in my project, I decided that I did not like the std::shared_ptr. I can't ...
Super Cyb0rg's user avatar
5 votes
1 answer
1k views

Graceful thread shutdown with std::move [closed]

I have a thread as part of a class that access the class's data members. The class has a move constructor that moves some of the old class's data members into the new object being constructed. Before ...
Sagar Jha's user avatar
  • 161
1 vote
1 answer
105 views

Single Linked List - simple approach

I am a student, trying to learn C++11 and data structures. I would like to ask you to to review my code. I have spent some time and analyse similar questions on Code Review and it gave me basic idea ...
pb.'s user avatar
  • 133
3 votes
2 answers
4k views

Copy-and-Move Concept Using Smart Pointer

I tried to implement a simple container class using the copy-and-move idiom. I am learning the changes to C++ as of C++11 and later. Is the code exception safe? I chose to use a smart pointer. Is <...
Henning's user avatar
  • 31
11 votes
2 answers
3k views

Trie Data Structure Implementation in C++11 using Smart Pointers -- follow-up

Link to my first question. Link to my latest source code. I followed @JDługosz recommendations. How does it look? Do you have any further recommendations? Is it better (if possible) to replace ...
user avatar
1 vote
1 answer
2k views

Returning containers from function - C++ [closed]

I've been trying to implement a few interfaces for processing data. And most of the time I do new of container and return a smart pointer to this container. ...
Shivendra Mishra's user avatar
1 vote
0 answers
1k views

C++11 CLH Lock Implementation

As a hobbyist programmer I have been reading "The Art of Multiprocessor Programming" (Herlihy, Maurice; Shavit, Nir) and converting the Java spin locks into C++ - I have enjoyed this and learned a lot....
headwedge's user avatar

15 30 50 per page