Is there something akin to the post increment operator to set an origin pointer to null ?
Wanted behaviour:
Class MyClass{
public:
int * ptr;
MyClass( MyClass && origin) noexcept;
MyClass(){}
};
MyClass::MyClass( MyClass && origin) noexcept:
ptr(origin.ptr){origin.ptr=nullptr};
Workaround with wanted semantic:
int * moveptr(int * & ptr){
int * auxptr=ptr;
ptr=nullptr;
return auxptr;
}
MyClass::MyClass( MyClass && origin) noexcept: ptr(moveptr( origin.ptr)){};
Maybe I'm missing something from the standard, but I couldn't find anything to represent a type of pointer to represent not ownership but also the prevents accidental sharing of a pointer.
I could use an unique_ptr with a custom deleter that does nothing, but that'd make the original assignment of the pointer weird.