Hi everyone,
can you explain me why this code DOES compile:

/*-------------------------------------------------------*/
import std.range, std.random;
void main()
{
        int[] vowels = ['A', 'E', 'I', 'O', 'U'];
        static assert(isInputRange!(typeof(vowels)));
        auto x = randomSample(vowels, 1);
}
/*-------------------------------------------------------*/

but this DOES NOT:

/*-------------------------------------------------------*/
import std.range, std.random;
void main()
{
        char[] vowels = ['A', 'E', 'I', 'O', 'U'];
        static assert(isInputRange!(typeof(vowels))); //pass
        auto x = randomSample(vowels, 1); //fail
}
/*-------------------------------------------------------*/
main.d(6): Error: template std.random.randomSample(R) if (isInputRange!(R)) does not match any function template declaration main.d(6): Error: template std.random.randomSample(R) if (isInputRange!(R)) cannot deduce template function from argument types !()(char[],int)

Reply via email to