On Tuesday, 30 March 2021 at 19:47:41 UTC, novice2 wrote:
My tries to make template for struct and alias this:

////// variant 1
template Typedef(alias Tnew, Tbase)
{
  struct Tnew
  {
    Tbase payload;
    alias payload this;
  }
}


you must give a name to the template specialization, using alias [1], also the TypeDef declaration can be highly simplified:

---
struct Typedef(TBase)
{
   TBase payload;
   alias payload this;
}

alias Xobj = Typedef!(void*);

void foo (Xobj obj) {}
---


[1]: https://dlang.org/spec/declaration.html#alias

Reply via email to