Maven (famous) to Programmer [email protected] • 1 month agoI love new featureslemmy.zipimagemessage-square35fedilinkarrow-up1342arrow-down14
arrow-up1338arrow-down1imageI love new featureslemmy.zipMaven (famous) to Programmer [email protected] • 1 month agomessage-square35fedilink
minus-square@[email protected]linkfedilink17•edit-21 month agoBecause 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.
minus-square@marcoslink5•1 month agoYeah… 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.
minus-square@[email protected]linkfedilink3•1 month agoIn C++ you should never have owning raw pointers. Unless you have a good reason™. Raw pointers are great, but not for ownership.
minus-square@[email protected]linkfedilink4•1 month agoAnd you should. It even works for classes whose constructors your implementation cannot see, if you aren’t a bitch about it.
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.
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.
In C++ you should never have owning raw pointers. Unless you have a good reason™.
Raw pointers are great, but not for ownership.
I just use
unique_ptr
99% of the timeAnd you should.
It even works for classes whose constructors your implementation cannot see, if you aren’t a bitch about it.