Policy Based Design Fehler?
-
Hallo,
ich versuche mich gerade an einer Vector- und Matrix Klasse mit Policy Based Design. Ich möchte jeweils den Allocator spezifizieren.Allerdings bekomme ich es nicht hin, dass man beim Mat-Konstruktor einen Vec als Parameter übergeben kann.
Hier der Code:
template <class T, int S> class VecAlloc { public: T data[S]; }; template <class T, int M, int N> class MatAlloc { public: T data[M*N]; T operator()(int row, int col) const { return data[row + M*col]; } T& operator()(int row, int col) { return data[row + M*col]; } }; template<class T, int S, template <class, int> class Alloc> class Vec : public Alloc<T,S> { public: Vec() { } Vec(const T& x, const T& y, const T& z, const T& w) { } }; template<class T, int N, int M, template <class, int, int > class Alloc> class Mat : public Alloc<T,N,M> { public: Mat() { } template<class T1, int S1, template <class,int> class Alloc2> Mat(const Vec<T1,S1,Alloc2>& v, const Vec<T1,S1,Alloc2>& v2) { } }; int main() { typedef Mat<float,4,4,MatAlloc> Mat4; typedef Vec<float,4,VecAlloc> Vec4; Mat4 t(Vec4(), Vec4()); t(0,0) = 1.0f; }Codepad:
http://codepad.org/rcYv6FZsBeim Compilen bekomme ich folgenden Fehler:
In function 'int main()':
Line 54: error: no match for 'operator=' in 't(0u, 0u) = 1.0e+0f'An was kann das liegen?
Danke!
-
Mat4 t(Vec4(), Vec4());ist dooferweise eine Funktionsdeklaration. (Most vexing parse) Klammer einen der Parameter, z.b. so:Mat4 t((Vec4()), Vec4());und dann gehts.