New answers tagged

8 votes

First dynamic array in C

Your code does not implement a dynamic array. It never extends its memory when elements are added, so it overflows its bounds after a number of insertions, and proceeds to overwrite memory it doesn't ...
Toby Speight's user avatar
  • 74.4k
0 votes

Tracker for object construction, copy, and movement

One obvious metric we could be gathering is the number of times the destructor is called, which should add up to the same number as the total of constructor calls if the container is behaving ...
Toby Speight's user avatar
  • 74.4k
1 vote

C++ shared_ptr memory pool

I think it would be more useful to give out unique pointers, which can be converted to shared pointers by the customer. The reverse isn't possible. Of course, the disadvantage to that is that the ...
Toby Speight's user avatar
  • 74.4k
3 votes
Accepted

Track and trace allocations

Missing thread-safety The default allocator is thread-safe, and custom allocators might also be. So for your allocator adapters to not destroy the thread-safety, you need to make sure you handle that ...
G. Sliepen's user avatar
6 votes
Accepted

A fixed-size dynamic array

Note: although the question is tagged C++17, I'm going to use some C++20 or later features in my review, as this simplifies the code. Many of my suggestions can be written in C++17, but at the ...
Toby Speight's user avatar
  • 74.4k
3 votes

Buddy - Algorithm in Rust

Small Stuff As J_H mentioned, there are more efficient ways to compute log2 of a u32 - ...
ChrisWue's user avatar
  • 20.3k

Top 50 recent answers are included