use of struct vs class

drug drug2004 at bk.ru
Sat Mar 7 12:24:18 UTC 2020


07.03.2020 13:58, mark пишет:
> change #1:
> 
>                  if (line.empty) {
>                      if (deb != null && deb.valid)
>                          debs.insert(deb);
>                      else // report incomplete
>                      deb = null;
>                      continue;
>                  }
>                  if (deb == null)
>                      deb = new Deb;
> 
> change #2: gets rid of most errors:
> 
>      bool opEquals(const Deb* other) const @safe pure nothrow {
> 
>      int opCmp(ref const Deb* other) const {
> 
> Just changed to pointers & moved to a separate file.
> 
> So now I just have one error in line 12 of model.d:
> 
> RedBlackTree!Deb* debs; // name-ordered list of deb packages LINE 12
> 
> 
> Performing "debug" build using 
> /home/mark/opt/ldc2-1.20.0-linux-x86_64/bin/ldc2 for x86_64.
> gtk-d:gtkd 3.9.0: target for configuration "library" is up to date.
> debfind ~master: building configuration "application"...
> src/model.d(12,9): Error: template instance 
> std.container.rbtree.RedBlackTree!(Deb) does not match template 
> declaration RedBlackTree(T, alias less = "a < b", bool allowDuplicates = 
> false)
>    with T = Deb
>    must satisfy the following constraint:
>         is(typeof(binaryFun!less(T.init, T.init)))
> /home/mark/opt/ldc2-1.20.0-linux-x86_64/bin/ldc2 failed with exit code 1.
> 

try
```
RedBlackTree!(Deb*) debs;
```


More information about the Digitalmars-d-learn mailing list