Bug 5640 – error with constructing RedBlackTree from range of array (typesafe variadics)

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2011-02-22T01:29:00Z
Last change time
2012-07-23T14:49:42Z
Keywords
rejects-valid
Assigned to
nobody
Creator
lutger.blijdestijn

Comments

Comment #0 by lutger.blijdestijn — 2011-02-22T01:29:22Z
The following does not compile: auto tree = RedBlackTree!string("foo", "bar", "baz"); Error message: Error: template std.container.RedBlackTree!(string).RedBlackTree.__ctor(U) if (isImplicitlyConvertible!(U,Elem)) does not match any function template declaration Error: template std.container.RedBlackTree!(string).RedBlackTree.__ctor(U) if (isImplicitlyConvertible!(U,Elem)) cannot deduce template function from argument types !()(string,string,string)
Comment #1 by lutger.blijdestijn — 2011-02-22T01:30:04Z
It is an issue with type inference from typesafe variadics, the constructor for RedBlackTree deduces U to immutable(char) rather than string: this(U)(U[] elems...) if (isImplicitlyConvertible!(U, Elem))
Comment #2 by ellery-newcomer — 2012-07-23T14:49:42Z
auto tree = redBlackTree!string("foo", "bar", "baz"); compiles with dmd 2.059