DList - Various Comments/Questions
H. S. Teoh
hsteoh at quickfur.ath.cx
Thu Dec 13 19:58:04 PST 2012
On Fri, Dec 14, 2012 at 03:33:31AM +0100, Chris Williams wrote:
[...]
> I also notice that the compiler is unable to detect struct
> initializers when I try to init my DList.
>
> E.g.:
>
> struct SomeData {
> string a;
> string b;
> }
> alias DList!(SomeData) SomeList;
>
> SomeList queue;
>
> static this() {
> queue = SomeList([
> {"Foo", "Bar"} // Compiler error
> ]);
> }
[...]
This should work:
queue = SomeList([
SomeData("Foo", "bar")
]);
A little verbose, but it should work.
> I also noticed that this doesn't work either:
>
> static this() {
> SomeData curr;
>
> curr = {"Foo", "Bar"}; // Compiler error
[...]
The usual idiom is:
auto curr = SomeData("Foo", "Bar");
T
--
Always remember that you are unique. Just like everybody else. -- despair.com
More information about the Digitalmars-d
mailing list