Hi all.
Finally, I arrived at something like this:
´´´
void main()
{
S!(sarr)[] sarr;
}
struct S(alias Reference)
{
size_t id()
in
{
// not static assert, only because a pointer is never known in
advance
assert(Reference.ptr <= &this);
}
do
{
return &this - Reference.ptr;
}
}
´´´
Of course, this does not compile, because I try to use an
identifier before I defined it.
However, the reason I dare to ask is, that all the stuff with the
weird self reference is compile time known.
So, is there a possibility to define something like the thing
above?