make_shared, weak_ptr and Control Block

Github Link

I added weak ptr functionality and make_shared to my C++ smart pointer sandbox and thought I'd share the core ideas here. Also as a side note, I think most text you see online these days are AI generated and it feels a little dull — so from now on, everything you see here or on my blog will be fully my words. Please comment or PM me if you disagree with anything or if I missed out on anything!

1. Weak Ptr

2. make_shared

Advantages

3. Memory Alignment Requirements

When creating my object of type U within the buffer inside the InplaceControlBlock struct, I used alignas(U). This ensures that the object adheres to the memory alignment requirements of type U. This got me thinking — why do certain objects require alignment to a boundary of a certain size?

And more importantly:

Cache Line Efficiency