no size yet for forward reference for nested structures
ketmar via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jan 14 02:53:54 PST 2015
On Wed, 14 Jan 2015 10:41:07 +0000
qqiang via Digitalmars-d <digitalmars-d at puremagic.com> wrote:
> template PowerHeap(T) {
> import std.container : SList;
>
> private alias PowerForest = SList!PowerNode;
>
> private final class PowerNode {
> private {
> T payload_;
> uint rank_;
> PowerForest children_;
> }
> }
>
> final class PowerHeap {
> private {
> PowerNode top_;
> PowerForest forest_;
> uint size_;
> }
> }
> }
>
> unittest {
> PowerHeap!int h;
> }
there is a circular dependency in your data structures. you're defining
`PowerNode` in the terms of... `PowerNode`. this won't work.
your `PowerForest` definition depends of complete `PowerNode`
definition, but `PowerNode` definition depends of complete
`PowerForest` definition.
don't do that.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150114/159b13b5/attachment.sig>
More information about the Digitalmars-d
mailing list