Passing Tuple Arguments to Tuple
Xinok
xnknet at gmail.com
Sun Dec 24 19:47:30 PST 2006
I was experimenting with recursive templates. I successfully created a
template which could test if a value is prime or not. What I tried to do next
is create another template which would use a tuple to build a list of primes.
template IsPrime(uint V, uint M = 2){
static if(V == 0 || V == 1) const bool IsPrime = false;
else static if(M*M <= V){
static if(V%M == 0) const bool IsPrime = false;
else const bool IsPrime = IsPrime!(V, M+1);
}
else const bool IsPrime = true;
}
template FindPrime(V...){
static if(V[0] < 2){
alias V[1..length] FindPrime;
}
static if(IsPrime!(V[0])){
alias FindPrime!(V[0]-1, V[0..length]) FindPrime; // Error: 'tuple V is used
as a type'
}
else{
alias FindPrime!(V[0]-1, V[1..length]) FindPrime;
}
}
This error makes no sense to me. What's the problem? Why can't you pass tuples
to tuples?
More information about the Digitalmars-d
mailing list