Thread overview | |||||
---|---|---|---|---|---|
|
October 07, 2012 Assign to element of DList | ||||
---|---|---|---|---|
| ||||
The docs for std.container suggest I should be able to do this: import std.container; void main() { auto list = DList!int([1,2,3,4,5]); list.front = 3; } But this does not compile (not a property list.front). I can't figure out why this doesn't work though - the source for struct DList(T) contains this: static if(isAssignable!(T,T)) { @property void front(T value) { assert(!empty, "DList.front: List is empty"); move(value, _first._payload); } } but that does not seem to be getting compiled in. |
October 07, 2012 Re: Assign to element of DList | ||||
---|---|---|---|---|
| ||||
Posted in reply to cal | On 10/07/2012 12:07 PM, cal wrote:
> The docs for std.container suggest I should be able to do this:
>
> import std.container;
>
> void main()
> {
> auto list = DList!int([1,2,3,4,5]);
> list.front = 3;
> }
>
> But this does not compile (not a property list.front). I can't figure
> out why this doesn't work though - the source for struct DList(T)
> contains this:
>
> static if(isAssignable!(T,T))
> {
> @property void front(T value)
> {
> assert(!empty, "DList.front: List is empty");
> move(value, _first._payload);
> }
> }
>
> but that does not seem to be getting compiled in.
>
What version of Phobos are you using? The source code of Phobos that comes with dmd 2.060 does not have the definition that you have shown.
In any case, according to the docs, it is SList that allows setting the front element, not DList:
import std.container;
void main()
{
auto list = SList!int([1,2,3,4,5]);
list.front = 3;
}
Ali
|
October 07, 2012 Re: Assign to element of DList | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Sunday, 7 October 2012 at 19:42:18 UTC, Ali Çehreli wrote:
> What version of Phobos are you using? The source code of Phobos that comes with dmd 2.060 does not have the definition that you have shown.
>
> In any case, according to the docs, it is SList that allows setting the front element, not DList:
>
> import std.container;
>
> void main()
> {
> auto list = SList!int([1,2,3,4,5]);
> list.front = 3;
> }
>
> Ali
Ah you're right, I was looking at my git head version, which I don't use when I build dmd head. So the functionality is there already. Thanks!
|
Copyright © 1999-2021 by the D Language Foundation