<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Policy Based Design Fehler?]]></title><description><![CDATA[<p>Hallo,<br />
ich versuche mich gerade an einer Vector- und Matrix Klasse mit Policy Based Design. Ich möchte jeweils den Allocator spezifizieren.</p>
<p>Allerdings bekomme ich es nicht hin, dass man beim Mat-Konstruktor einen Vec als Parameter übergeben kann.</p>
<p>Hier der Code:</p>
<pre><code class="language-cpp">template &lt;class T, int S&gt;
	class VecAlloc
	{
	public:
		T data[S];
	};
	template &lt;class T, int M, int N&gt;
	class MatAlloc
	{
	public:
		T data[M*N];
		T operator()(int row,  int col) const
		{
			return data[row + M*col];
		}
		T&amp; operator()(int row,  int col)
		{
			return data[row + M*col];
		}
	};
	template&lt;class T, int S, template &lt;class, int&gt; class Alloc&gt;
	class Vec : public Alloc&lt;T,S&gt;
	{
	public:
		Vec()
		{
		}
		Vec(const T&amp; x, const T&amp; y, const T&amp; z, const T&amp; w)
		{
		}
	};

	template&lt;class T, int N, int M,  template &lt;class, int, int &gt; class Alloc&gt;
	class Mat : public Alloc&lt;T,N,M&gt;
	{
	public:
		Mat()
		{
		}

		template&lt;class T1, int S1, template &lt;class,int&gt; class Alloc2&gt;
		Mat(const Vec&lt;T1,S1,Alloc2&gt;&amp; v,
			const Vec&lt;T1,S1,Alloc2&gt;&amp; v2)
		{

		}
	};
int main()
{
	typedef Mat&lt;float,4,4,MatAlloc&gt; Mat4;
	typedef Vec&lt;float,4,VecAlloc&gt; Vec4;
	Mat4 t(Vec4(), Vec4());
	t(0,0) = 1.0f;
}
</code></pre>
<p>Codepad:<br />
<a href="http://codepad.org/rcYv6FZs" rel="nofollow">http://codepad.org/rcYv6FZs</a></p>
<p>Beim Compilen bekomme ich folgenden Fehler:<br />
In function 'int main()':<br />
Line 54: error: no match for 'operator=' in 't(0u, 0u) = 1.0e+0f'</p>
<p>An was kann das liegen?</p>
<p>Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/297592/policy-based-design-fehler</link><generator>RSS for Node</generator><lastBuildDate>Fri, 14 Aug 2026 10:08:29 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/297592.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 02 Jan 2012 17:59:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Policy Based Design Fehler? on Mon, 02 Jan 2012 17:59:09 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich versuche mich gerade an einer Vector- und Matrix Klasse mit Policy Based Design. Ich möchte jeweils den Allocator spezifizieren.</p>
<p>Allerdings bekomme ich es nicht hin, dass man beim Mat-Konstruktor einen Vec als Parameter übergeben kann.</p>
<p>Hier der Code:</p>
<pre><code class="language-cpp">template &lt;class T, int S&gt;
	class VecAlloc
	{
	public:
		T data[S];
	};
	template &lt;class T, int M, int N&gt;
	class MatAlloc
	{
	public:
		T data[M*N];
		T operator()(int row,  int col) const
		{
			return data[row + M*col];
		}
		T&amp; operator()(int row,  int col)
		{
			return data[row + M*col];
		}
	};
	template&lt;class T, int S, template &lt;class, int&gt; class Alloc&gt;
	class Vec : public Alloc&lt;T,S&gt;
	{
	public:
		Vec()
		{
		}
		Vec(const T&amp; x, const T&amp; y, const T&amp; z, const T&amp; w)
		{
		}
	};

	template&lt;class T, int N, int M,  template &lt;class, int, int &gt; class Alloc&gt;
	class Mat : public Alloc&lt;T,N,M&gt;
	{
	public:
		Mat()
		{
		}

		template&lt;class T1, int S1, template &lt;class,int&gt; class Alloc2&gt;
		Mat(const Vec&lt;T1,S1,Alloc2&gt;&amp; v,
			const Vec&lt;T1,S1,Alloc2&gt;&amp; v2)
		{

		}
	};
int main()
{
	typedef Mat&lt;float,4,4,MatAlloc&gt; Mat4;
	typedef Vec&lt;float,4,VecAlloc&gt; Vec4;
	Mat4 t(Vec4(), Vec4());
	t(0,0) = 1.0f;
}
</code></pre>
<p>Codepad:<br />
<a href="http://codepad.org/rcYv6FZs" rel="nofollow">http://codepad.org/rcYv6FZs</a></p>
<p>Beim Compilen bekomme ich folgenden Fehler:<br />
In function 'int main()':<br />
Line 54: error: no match for 'operator=' in 't(0u, 0u) = 1.0e+0f'</p>
<p>An was kann das liegen?</p>
<p>Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2162984</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2162984</guid><dc:creator><![CDATA[DerCoder0815]]></dc:creator><pubDate>Mon, 02 Jan 2012 17:59:09 GMT</pubDate></item><item><title><![CDATA[Reply to Policy Based Design Fehler? on Mon, 02 Jan 2012 18:11:43 GMT]]></title><description><![CDATA[<p><code>Mat4 t(Vec4(), Vec4());</code> ist dooferweise eine Funktionsdeklaration. (Most vexing parse) Klammer einen der Parameter, z.b. so: <code>Mat4 t((Vec4()), Vec4());</code> und dann gehts.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2162991</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2162991</guid><dc:creator><![CDATA[jokester_]]></dc:creator><pubDate>Mon, 02 Jan 2012 18:11:43 GMT</pubDate></item></channel></rss>