SOme fun with D compiler
Daniel Kozak via Digitalmars-d
digitalmars-d at puremagic.com
Tue Oct 18 01:21:09 PDT 2016
Try to compile this:
import std.stdio;
auto xxx(T)()
{
return this;
}
struct S
{
mixin xxx!(typeof(this));
alias xxx this;
}
void foo(S pos)
{
writefln("(%.2f|%.2f)", pos.x, pos.y);
}
void main()
{
}
Or this:
import std.stdio;
auto xxx(T)()
if (is(T == struct))
{
return this;
}
struct Vector2f
{
mixin xxx!(typeof(this));
alias xxx this;
}
void foo(ref const Vector2f pos) {}
void main()
{
Vector2f v;
foo(v);
}
More information about the Digitalmars-d
mailing list