Template constraint error.

Gary Willoughby dev at nomad.so
Thu Oct 10 07:46:18 PDT 2013


Using Debian7, gcc-4.8, gdc-4.8 from the `testing main` debian 
source.

         import std.stdio;

         class Bar(T) if (is(T == int))
         {
                 this()
                 {
                         writefln(T.stringof);
                 }
         }

         class Foo(T) : Bar!(int) if (is(T == string)) // <-- 
template constraint causes error.
         {
                 this()
                 {
                         super();
                         writefln(T.stringof);
                 }
         }

         void main()
         {
                 auto baz = new Foo!(string)();
         }

$ gdc test.d -o test

test.d:11: Error: members expected
test.d:11: Error: { } expected following aggregate declaration
test.d:11: Error: Declaration expected, not 'if'
test.d:16: Error: function declaration without return type. (Note 
that constructors are always named 'this')
test.d:16: Error: no identifier for declarator 
writefln(T.stringof)
test.d:17: Error: unrecognized declaration


More information about the D.gnu mailing list