template condition
Andrej Mitrovic
andrej.mitrovich at gmail.com
Thu Sep 27 06:54:14 PDT 2012
On 9/27/12, Timon Gehr <timon.gehr at gmx.ch> wrote:
> snip
Perhaps he meant something like this:
struct Foo(T : Object) { }
struct Foo(T) if (is(T : Object )) { }
void main()
{
Foo!Object x;
}
The difference is the first template is a specialization, and the
second has a constraint. The first one will match better than the
second one even though both templates can be instantiated with
'Object'.
The constraint version is more flexible but the specialization might
be shorter to write. http://dlang.org/template.html
More information about the Digitalmars-d-learn
mailing list