tango list
Bill Baxter
dnewsgroup at billbaxter.com
Wed Feb 27 13:35:40 PST 2008
Robert Fraser wrote:
> Christopher Wright wrote:
>> quest wrote:
>>> hi,
>>>
>>> i would like to hand over some LinkSeq list to some funktions. what
>>> would be function header??
>>>
>>>
>>> void testfunc(???? lists, int bolony) { .... }
>>>
>>> seems like i can't use LinkSeq for the ????.
>>
>> // Use a list of any type of element
>> void testfunc(T)(ListSeq!(T) list, int bologna) {}
>>
>> Unfortunately, you won't be able to put that in an interface.
>
> Why not?
>
> interface ResultCollector
> {
> void notify(Result r);
> void notify(Seq!(Result) results);
> Seq!(Result) getResults();
> }
You can't put a template in an interface, just a particular
instantiation of one, as you've done there. Try it with
void notify(Result)(Seq!(Result) results);
I'm not sure if it's even possible to make that work. It basically says
the interface contains a family of functions and you aren't sure which
ones yet.
'Course you *can* make a templated interface:
interface ResultCollector(Result)
{
void notify(Result r);
void notify(Seq!(Result) results);
Seq!(Result) getResults();
}
--bb
More information about the Digitalmars-d-learn
mailing list