• @[email protected]
    link
    fedilink
    17
    edit-2
    1 month ago

    Because stuff can own other stuff and be owned at the same time. Also, arcane jackarsery.

    Edit: if you want to give a function a pointer that it may change this may occur in a constructive way. I.e. replace an owned object.

    • @marcos
      link
      51 month ago

      Yeah… But it’s usually a good practice to put a struct somewhere between your 30 levels of ownership.

      Exceptions exist, but they are not very common. Also, in C++, operators overloading may help you if you keep needing to write code like this.

      • @[email protected]
        link
        fedilink
        31 month ago

        In C++ you should never have owning raw pointers. Unless you have a good reason™.

        Raw pointers are great, but not for ownership.

        • qaz
          link
          English
          6
          edit-2
          1 month ago

          I just use unique_ptr 99% of the time

          • @[email protected]
            link
            fedilink
            41 month ago

            And you should.

            It even works for classes whose constructors your implementation cannot see, if you aren’t a bitch about it.