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

ความคิดเห็น • 11

  • @arghyadeepmandal4458
    @arghyadeepmandal4458 ปีที่แล้ว +2

    Really good content 😃

  • @chiragbansal8129
    @chiragbansal8129 ปีที่แล้ว +4

    These things are completely anonymous to us . Can you recommend a book which includes such content ? Like quant books always have puzzles / maths only .

    • @CodingInterviewPrep
      @CodingInterviewPrep  ปีที่แล้ว +3

      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.

    • @chiragbansal8129
      @chiragbansal8129 ปีที่แล้ว

      @@CodingInterviewPrepthat’s what I was thinking . Thanks a lot for the work !!

    • @CodingInterviewPrep
      @CodingInterviewPrep  ปีที่แล้ว +2

      @@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.

    • @CodingInterviewPrep
      @CodingInterviewPrep  ปีที่แล้ว +1

      @@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.

  • @ebadjunaid9418
    @ebadjunaid9418 8 หลายเดือนก่อน

    bro great I have a question how unique ptr handles that arrays can you make a video on that ?

  • @sunnyyasser5625
    @sunnyyasser5625 ปีที่แล้ว

    do you maintain a repo of all the codes as well?

  • @praveensingh2060
    @praveensingh2060 7 หลายเดือนก่อน

    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