On Sunday, 22 August 2021 at 14:40:29 UTC, james.p.leblanc wrote:
It is a bit scary how you guessed very closely what I am trying
to
do. I have a AVX aligned pointers (obtained from fftw_malloc),
that I
want to protect.
To be a bit more specific. The code that reads/writes from
to/from fftw
routines is all pointer based. But, to allow use of standard
dlang things
such as "foreach" and friends, I've been cobbling together a
(naive) wrapper.
This allows me to use standard dlang syntax and operator
overloads. I call my
struct "fakeArray" ... since it is meant to behave either as a
static array,
or a dynamic array as needed.
It **seems** to work pretty well ... but protecting the arrays
from accidental
programming mistakes (such as the "auto y=x") has been eluding
me.
OK, rather than roll your own solution, Unique!Foo might do what
you want, from https://dlang.org/phobos/std_typecons.html#Unique