Skip to main content

All Questions

6 votes
4 answers
1k views

Packing and unpacking values in a buffer

I have to deal with raw memory manipulation. For that I wrote a function which stores data one after another, and another function which reads this data and stores it into variables. More precisely: <...
tommsch's user avatar
  • 243
9 votes
3 answers
5k views

A Tic Tac Toe game in C++

I am a beginner programmer and have made a tic tac toe program in c++. I need some help with my memory management can anyone review and help me. This is my code ...
Vedant Matanhelia's user avatar
4 votes
1 answer
133 views

Unique and shared resource owner

I need a unique_ptr and shared_ptr like structure, but instead of pointers, I would like to store some kind of reference to a ...
Adam's user avatar
  • 63
2 votes
0 answers
108 views

A lightweight version of std::shared_ptr<T> V2

This is a lightweight version of std::shared_ptr<T> called res_ptr<T> This post is a continuation of: A lightweight ...
ALX23z's user avatar
  • 2,368
7 votes
2 answers
577 views

A lightweight version of std::shared_ptr<T>

I wrote a simple lighter version of std::shared_ptr<T> called res_ptr<T>. ...
ALX23z's user avatar
  • 2,368
5 votes
2 answers
595 views

A free-standing weak_ptr equivalent to handle lifetime of non-shared callback objects

I've been finding myself wanting the following pattern recently: ...
user avatar
3 votes
0 answers
296 views

A way to automatically reorder struct fields by their sizes in descending order

Using constexpr and preprocessor magic it is possible to cook a struct which have a minimal size between all possible sizes, keeping all the data members properly ...
Tomilov Anatoliy's user avatar
21 votes
3 answers
9k views

A vector-like polymorphic container to store objects from a type hierarchy in contiguous memory

Normally, in order to have a polymorphic collection, we store pointers to a base class: ...
user2296177's user avatar
  • 3,543
4 votes
1 answer
615 views

Memory allocation tracking using anonymous lambda wrapper

I had this idea to exploit anonymous lambdas that are immediately executed that wrap around an allocation function to track those allocations in a statically created Stats object. This is the code I ...
Adrian Lis's user avatar
4 votes
0 answers
312 views

cross-platform stdlib-only aligned allocator in C++14

I'm writing a program which uses OpenCL, and the OpenCL types are mostly over-aligned. Sometimes when using stl containers with these types, I'd get segfaults, so I tried to write my own aligned ...
Reuben Thomas's user avatar
22 votes
1 answer
644 views

Aligning your heterogenous uninitialized memory to make the processor happy

After learning more about memory alignment and how it can impact processor data access, I tried to find something in the standard that offers proper memory alignment inside blocks of raw memory that ...
user2296177's user avatar
  • 3,543
8 votes
1 answer
330 views

Return sizeof a struct containing members ordered like given template parameters

...
Brian Rodriguez's user avatar
9 votes
4 answers
38k views

Using std::unique_ptr and std::move

I'm trying out new things (on class Inproc), specifically using std::unique_ptr and std::move...
Goswin von Brederlow's user avatar
1 vote
2 answers
25k views

std::vector of pointers with the rule of three

I have a class that has a std::vector of pointers, I'm NOT going to give any of those pointers to objects outside of it, I mean, I'm not going to share the pointers....
yayuj's user avatar
  • 185
7 votes
4 answers
5k views

Simple resizable array

In some (lower-level) parts of my codebase I often have the need to allocate resizable array storage for certain objects, that usually are not default-constructible. I created a simple class using <...
Vittorio Romeo's user avatar