This code should compile:
interface OutputRange(T...) if (T.length == 1)
{
void put(T[0] value);
}
interface OutputRange(T...) : OutputRange!(T[0]), OutputRange!(T[1 .. $])
if (T.length > 1)
{
}
The first error is "members expected" upon the "if" clause in the second definition, which suggests that the syntax is not yet supported.
Comment #1 by samukha — 2010-01-05T03:00:42Z
This syntax is supported:
interface OutputRange(T...) if (T.length > 1)
: OutputRange!(T[0]), OutputRange!(T[1 .. $])
{
}
Comment #2 by samukha — 2010-01-05T04:22:26Z
Also, each interface adds sizeof(void*) bytes to the class instance size. While recursive inheritance provides a separate interface for each type, which may be a nice property, the overhead, for example, of OutputRange!basicTypes would be significant.
Comment #3 by andrei — 2010-01-05T06:04:40Z
Thanks, Max. Yah, the overhead is kinda crippling. I'm also thinking of TextOutputRange, which is an alias for OutputRange!(const(char)[], const(wchar)[], const(dchar)[], char, wchar, dchar). That would be 24 bytes to boot. Maybe I better use a recursive mixin to generate all functions inside the interface.
Comment #4 by Kosmonaut — 2010-08-20T20:55:45Z
*** Issue 4698 has been marked as a duplicate of this issue. ***