Error: template cannot deduce function from argument types.
anonymous via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Aug 24 03:35:24 PDT 2014
On Sunday, 24 August 2014 at 02:53:41 UTC, Damian Day wrote:
> Hi, I've been trying to reduce a bug in the containers (8824).
>
> From the example below it seems the dup method is passing the
> constructor
> an array of dchars and the template is failing.
>
> Is this a compiler bug, or ?
>
> import std.range, std.traits;
>
> struct Array2(T)
> {
> private T[] _payload;
>
> size_t insertAt(R)(size_t index, R rng)
> if (isInputRange!R &&
> isImplicitlyConvertible!(ElementType!R, T))
> {
> return 0;
> }
>
> this(U)(U[] values...)
> if (isImplicitlyConvertible!(U, T))
> {
> insertAt(0, values);
> }
>
> @property Array2 dup()
> {
> return Array2(_payload);
> }
> }
>
> unittest
> {
> Array2!int a; //passes
> Array2!char a; //fails
> }
Not a compiler bug. char[] (and wchar[]) as ranges auto-decode to
dchars. I.e. ElementType!(char[]) is dchar. And dchar isn't
implicitly convertible to char. So the instantiation of insertAt
fails.
More information about the Digitalmars-d-learn
mailing list