template magic

Trass3r un at known.com
Tue Jan 25 07:55:43 PST 2011

> 2. What is the reason for Phobos defining param funcs as template

Correct me if I'm wrong but there's no way to pass an arbitrary
function to a function in a type-safe way. If you use pointers and
casts you can't check if the passed function meets certain
requirements (parameters, return type, attributes, etc.)

> 3. What is the meaning of 'alias f'? How does it work? This is a
> enigmatic feature for me. Seems it allows placing anything of any
type as
> template param.

It allows you to pass any D symbol. As the name already suggests,
think of it as being a template-local alias to a symbol passed in the
instantiation (but note that you can also pass literals as arguments
to alias parameters).

More information about the Digitalmars-d-learn mailing list