Template Question
Jakob
name at domain.
Tue Apr 15 07:09:23 PDT 2008
BCS schrieb:
> 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));
While reading the posts of Mike and Bill above, i already wondered
whether every Foo!(T) should be a subtype of Foo implicitly, so it would
be possible to write "class Manager(U : Foo) {}"
Just a fix idea.
But if you can declare both Foo!(T) and Foo overloaded, FooBase could
simply be renamed to Foo in the example above.
More information about the Digitalmars-d-learn
mailing list