On Tuesday, 2 February 2016 at 21:18:27 UTC, maik klein wrote:
Could you share this? I would be very interested in how you
have approached it.
My ad hoc pointer experiments try to be general and is
convoluted, so not the best example. The basic idea is to have a
pointer type that match "&&" in C++ (which cannot be done
completely).
So we have something like:
struct moving(T){
T* ptr;
~this(){ assert(ptr is null); } // optional check to ensure
that the move is completed
}
then have a move() function that returns a moving!T struct
In you pointer struct you match opAssign(moving!T ...) to emulate
"operator=(T&& ...)" and set the ptr field to null to prevent it
from being used again (if you want that extra check).