On Monday, 3 November 2014 at 14:27:47 UTC, Dominikus Dittes
Scherkl wrote:
If I have a struct with numeric template parameter, how can I
access it within member functions? Like normal member
variables? And how about the constructor?
struct polynomial(uint base)
{
private:
uint[] N;
public:
this(uint x) { base = x; }
...
void add(Polynomial!base P)
{
if(N.length < P.N.length) N.length = P.N.length;
foreach(i; 0..P.N.length)
{
N[i] = (N[i]+P.N[i]) % base;
}
}
}
This doesn't work for me :-/
You cannot assign to it, because it is only avaliable during
compilation. Think of it as an immediate value, not variable.