Implement std::unique_ptr in C++
ฝัง
- เผยแพร่เมื่อ 26 พ.ย. 2022
- In this video I have explained how you can implement your own unique_ptr in C++.
________________________________________________________________________________________
Connect with me on Instagram: / shubham__cr7
Really good content 😃
Thanks ✌️
These things are completely anonymous to us . Can you recommend a book which includes such content ? Like quant books always have puzzles / maths only .
There is no book for this type of content. Atleast none that I know of. I learnt all these things by looking at the implementation of GCC and MSVC. Now I have compiled all this content in a 20 minute video so that it is easier for you guys to learn.
@@CodingInterviewPrepthat’s what I was thinking . Thanks a lot for the work !!
@@chiragbansal8129 You won't need a book anyways. In a span of 1 year I will try to create all these tutorials. Can't really guarantee that but I will try my best.
@@chiragbansal8129Although I've observed that in terms of view count and watch hours, these tutorial videos are the worst performing videos on my channel. So I might also decide not to create these in future.
bro great I have a question how unique ptr handles that arrays can you make a video on that ?
do you maintain a repo of all the codes as well?
No
Thanks for the amazing video. I tried implementing it on my own, can you tell the issues with this implementation (I'm aware it does not handles polymorphism, but can you highlight other issues/potential memory leaks etc?
template
class unique_ptr{
T* ptr;
public:
unique_ptr(T* x=nullptr):ptr(x){}
//we don't want to allow copy!
//delete copy constuctor and copy assignment!
unique_ptr(const unique_ptr& x) = delete;
unique_ptr& operator=(const unique_ptr& x) = delete;
//we need to make a move constructor and move assignment!
unique_ptr(unique_ptr&& x){
std::cout