so I'm trying to write (or rather learn how to write) a 'variadic template function', that returns just one of its variadic parameter, randomly chosen.

But can't get my head around the problem here :-(

.. Error: template `std.random.randomSample` cannot deduce function from argument types `

// --

module test;
import std;

string RandomChoice(R...)(R r)
{
    auto rnd = MinstdRand0(42);
    return r.randomSample(1, rnd).to!string;
}

void main()
{
    writeln( RandomChoice("typeA", "typeB", "typeC") );
}

// --

Reply via email to