templates
Steven Schveighoffer
schveiguy at yahoo.com
Mon Apr 19 19:33:25 PDT 2010
BLS Wrote:
> On 19/04/2010 20:16, Ellery Newcomer wrote:
> > Hello.
> >
> > Say I have a [struct] template T, which takes a param S.
> >
> > Any T!(S) satisfies a certain template constraint W, so I can use any
> > T!(S) the same way. I want to be able to store heterogeneous T!(S) in a
> > single list. Is there any good way to express the type for this?
>
> Why not simply...
>
> class C(O)
> {
> private O obj;
> object next;
> this(O obj)
> {
> this.obj = obj;
> }
> ...
> invariant()
> {
> assert(this.obj fulfills W);
> }
> ...
> }
W is a compile-time interface. this.obj is Object, so at compile time all you have are Object's methods.
So no, it can't simply be that.
-Steve
More information about the Digitalmars-d-learn
mailing list