how hash_t toHash() works?
Ivan Kazmenko
gassa at mail.ru
Mon Apr 29 09:01:14 PDT 2013
> one more question
> What is the type of cont?
>
> auto cont = redBlackTree !("a.key < b.key", true, MyRecord) ();
>
> I want to use this as a property in a class and i can't use
> there auto keyword... I tried different types but it did not
> work.
For me, the following declaration works:
-----
import std.functional;
...
RedBlackTree !(MyRecord, binaryFun!"a.key < b.key", true) cont;
...
cont = redBlackTree !("a.key < b.key", true, MyRecord) ();
-----
I admit it could have been easier to figure out. For example,
"writeln (typeof (cont).stringof);" just prints "RedBlackTree"
which is not enough for a proper declaration. I've inferred the
right declaration from the following lines in container.d:
-----
/++ Ditto +/
auto redBlackTree(alias less, bool allowDuplicates, E)(E[]
elems...)
if(is(typeof(binaryFun!less(E.init, E.init))))
{
//We shouldn't need to instantiate less here, but for some
reason,
//dmd can't handle it if we don't (even though the template
which
//takes less but not allowDuplicates works just fine).
return new RedBlackTree!(E, binaryFun!less,
allowDuplicates)(elems);
}
-----
More information about the Digitalmars-d-learn
mailing list