GSoC-2011 project:: Containers

Steven Schveighoffer schveiguy at yahoo.com
Tue Apr 5 08:03:08 PDT 2011


On Tue, 05 Apr 2011 10:44:48 -0400, Ishan Thilina <ishanthilina at gmail.com>  
wrote:

> -Steve wrote:
>
>> There are several problems with your code.
>>
>> I'd recommend not putting your code in std.container at first.  It will  
>> be
>> easier to deal with, because people will know which code you wrote and
>> also it will be better when posting code for questions.
>
> Yes, sorry for that :).
>
>>
>> I see two problems right off the bat:
>>
>> 1. your Range!T has two definitions for @property void front(T value)
>> 2. Range!T uses Node, which has no definition.
>>
>
> Rectified, but I still face problems.
>
>> I'm guessing you meant Range!T to be a part of Queue?  I'm not sure what
>> you are doing exactly, because there are no usages of Queue in your code
>> (i.e. it compiles because none of your templates are instantiated).  If
>> you want Range to be part of Queue, put it inside the definition of
>> Queue.  It will make things easier, and not pollute the namespace.
>> Range!T is not a good name to put in the global namespace.
>
> Yes, I want Range!T to be a part of the Queue. It's a forward range that  
> allows to
> iterate through he contents of the Queue.
>
>
> I still have the original problem I had. I get this error when I try to  
> compile.
>
> "
> /home/ishan/D/1.d(184): Error: no property 'opCall' for type  
> 'test.Queue!(int).Queue'

classes cannot be instantiated in-place like in C++.  They must be  
instantiated on the heap with a new statement:

auto nnn = new Queue!(int)(1);

note, however, that templated constructors are not allowed for classes,  
there is an open bug report on that (435).

I'd recommend using just the variadic constructor:

this(T[] values...)
{
    ...
}

After fixing these, it still does not compile, but I don't have time right  
now to look at the errors, perhaps you can work through them on your own.   
I encourage you to isolate problems with the code and write very small  
simple programs to test how the syntax works.  Then post questions to  
d.learn with small code examples if you still can't figure out why it  
doesn't work.

-Steve


More information about the Digitalmars-d mailing list