Hiho,

I am currently working on a matrix library (matrices are templated structs) and have just implemented so-called "ElementalOperations" which perform certain tasks on mutable matrices.

There is an abstract ElementalOperation where three different ElementalOperation types inherit from. These ElementalOperations are structured like that:

module neoLab.core.ScaleRowOperation;

import neoLab.core.ElementalOperation;
import neoLab.core.Matrix;

final class ScaleRowOperation(T = double) : ElementalOperation
        if (!hasIndirections!T)
{
        private
        {
                size_t row = 0;
                T factor = 1;
        }

        this(size_t row, T factor) pure nothrow {
                this.row = row;
                this.factor = factor;
        }

        override void opCall(ref Matrix m) pure nothrow {
                foreach (immutable col; 0 .. m.getDimension().cols) {
                        m[this.row, col] *= this.factor;
                }
        }

        override string toString() const pure nothrow {
                return "Scale all elements of row " ~ this.row ~
                                " by factor " ~ this.factor ~ ".";
        }
}

So it is a fairly simple concept until now and I haven't spend time on improving its performance as I run into a strange compiler error, telling me the following:

neoLab/core/ElementalOperation.d(6): Error: struct neoLab.core.Matrix.Matrix(T = double) if (!hasIndirections!T) is used as a type neoLab/core/SwapRowsOperation.d(18): Error: struct neoLab.core.Matrix.Matrix(T = double) if (!hasIndirections!T) is used as a type

The matrix struct is defined as follows:

struct Matrix(T = double) if (!hasIndirections!T)

In the documentation hasIndirections!T reads:
Returns true if and only if T's representation includes at least one of the following:
    - a  raw pointer U*;
    - an array U[];
    - a  reference to a class type C.
    - an associative array.
    - a  delegate.

I don't know why this error occures at all. In my opinion it shouldn't, or am I doing something wrong again?

Thanks in advance for help. =)

Robin

Reply via email to