Template Question
Mike Parker
aldacron71 at yahoo.com
Mon Apr 14 19:03:25 PDT 2008
BCS wrote:
> Mike Parker wrote:
>> I've not worked much with templates in any language beyond the basics.
>> Right now, I've got a problem that I've solved, but for which I'm
>> looking a different solution.
>>
>> What I have is a templated interface like so:
>>
>> interface Foo(T)
>> {
>> void init(T);
>> void term();
>> void blah();
>> void bleh();
>> }
>>
>
> quick-n-dirty (and untested)
>
> interface FooBase{}
> interface Foo(T) : FooBase
> {
> void init(T);
> void term();
> void blah();
> void bleh();
> }
>
> then throw this in somewhere:
>
> static assert(is(T:FooBase));
Good idea. And it would be perfect if I could hide FooBase inside the
module, but I recall reading somewhere that the compiler doesn't respect
private class and interface declarations. And a quick test proves it.
More information about the Digitalmars-d-learn
mailing list