Embedded Containers

A Guy With a Question aguywithanquestion at gmail.com
Tue Dec 5 19:01:48 UTC 2017


The following doesn't appear to be valid syntax. Array!Item!T

I get the following error:

"multiple ! arguments are not allowed"	

Which is ok...I get THAT error, however, this does not work 
either:

alias Items(T) = Array!Item(T);

This gives me the error:

Error: function declaration without return type. (Note that 
constructors are always named `this`)	

Item is defined as follows:

interface Item(T)
{
    @property
    T member();
}

That part compiles fine. However, even when I remove the 
aliasing, I can't import this interface. I get "Error: undefined 
identifier 'Item'"

I'm not quite sure I understand how to create a generic container 
interface or class in D. Half of how I expect it to work works, 
but the other half doesn't. The docs aren't too helpful. I'm not 
sure if it's a case where there's just too much to go through or 
if what I'm trying to do isn't really covered. Essentially I'm 
trying to create an array of this type 'Item' that has some 
generic members. I think people who come from C# will kind of get 
what I'm trying to do here, because I'm trying to port C# code.


More information about the Digitalmars-d mailing list