On Saturday, 3 December 2016 at 17:29:47 UTC, rumbu wrote:
On Saturday, 3 December 2016 at 16:37:21 UTC, Jerry wrote:
On Saturday, 3 December 2016 at 11:52:00 UTC, rumbu wrote:
[...]
[...]
[...]

Is that the exact code? isInputRange checks to see if the type has "front" defined.


https://github.com/dlang/phobos/blob/v2.072.0/std/range/primitives.d#L162

Also "string" is just an alias of an array, "immutable(char)[]". So an array should have "front" defined. Can you post more code?

No, an array should not have "front" defined according to D language specification. "front" for arrays is defined in std.range.primitives. That's the problem, I cannot have two specialized functions (one taking arrays and one taking ranges), because std.range.primitives hijacks any char array and transforms it in a range). front, empty, popFront must not be defined for arrays in the same module as isInputRange.

Exact code is irrelevant, but you're welcome:

string constructor: https://github.com/rumbu13/numerics/blob/master/src/numerics/fixed.d#L978

range constructor
https://github.com/rumbu13/numerics/blob/master/src/numerics/fixed.d#L1104

This works for me when specialising for input ranges, strings and arrays.

auto f(T)(T val)
    if(isInputRange!T && !isSomeString!T && !isArray!T) {}

auto f(T)(T val)
    if(isSomeString!T) {}

auto f(T)(T val)
    if(isArray!T && !isSomeString!T)

bye,
lobo

Reply via email to