One Trick on shared_ptr

I find that shared_ptr can correctly handle the deconstruction of the sub-class without virtual deconstruntor. Therefore, I searched for related references and conducted one trial to verify it.
I do not want to go deep in the source code, so I just introduce them by some examples simply.
What’s more, I think up one optimizing trick after further study.

Continue reading

Endianness

Endianness is an essential concept for Processors, and it often causes some terrible problems for programmers. This article briefly introduced the Endianness by a figure from GAMES104. What’s more, I know a Divide and Conquer method to reverse bits with O(1) for both space and time, so I modified and thus applied this method for reversing Endianness. The C++ code will be attached at the end.

Continue reading

Opaque Structure

Opaque Structure is an essential concept, which has been widely applied to low-layer codes like Operate Systems. In this article, I will make a brief introduction to Handle and Opaque Structure, which are two closely related concepts. What’s more, I will present a tentative implement at the end.

Continue reading