Extending UFCS
Piotr Szturmaj
bncrbme at jadamspam.pl
Wed Aug 29 13:36:06 PDT 2012
Piotr Szturmaj wrote:
> and instead of writing hash!SHA1("abc"), write SHA1.hash("abc");
Another example:
template MutablePointer(T)
{
alias PointerTarget!(Unqual!T) MutablePointer;
}
alias const(int) CInt;
static assert(is(MutablePointer!CInt == int*));
Alternative syntax:
template MutablePointer(T)
{
alias T.Unqual.PointerTarget MutablePointer;
}
alias const(int) CInt;
static assert(is(CInt.MutablePointer == int*));
This is just for convenience, as with UFCS. Second syntax is IMO a lot
cleaner.
More information about the Digitalmars-d
mailing list