<?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[variable anzahl von template parametern]]></title><description><![CDATA[<p>Hi,</p>
<p>template &lt;const size_t DIM1, const size_t DIM2&gt; ... kann ich die anzahl flexibel machen fuer den user?</p>
<p>ich habe folgende klasse, wie ihr hier sieht wird ein 2d array erzeugt wenn ich 2 template parameter uebergebe... kann ich irgendwie 3 parameter uebergeben und dann den konstructor orig(L1, L2, L3) aufrufen?</p>
<pre><code>template &lt;const size_t DIM1, const size_t DIM2&gt;
class foo {
private:
  array orig;

public:
  foo(): orig(DIM1, DIM2) {}
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/331462/variable-anzahl-von-template-parametern</link><generator>RSS for Node</generator><lastBuildDate>Fri, 01 May 2026 15:51:17 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/331462.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 02 Mar 2015 08:54:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to variable anzahl von template parametern on Mon, 02 Mar 2015 08:54:47 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>template &lt;const size_t DIM1, const size_t DIM2&gt; ... kann ich die anzahl flexibel machen fuer den user?</p>
<p>ich habe folgende klasse, wie ihr hier sieht wird ein 2d array erzeugt wenn ich 2 template parameter uebergebe... kann ich irgendwie 3 parameter uebergeben und dann den konstructor orig(L1, L2, L3) aufrufen?</p>
<pre><code>template &lt;const size_t DIM1, const size_t DIM2&gt;
class foo {
private:
  array orig;

public:
  foo(): orig(DIM1, DIM2) {}
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2444893</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2444893</guid><dc:creator><![CDATA[templator]]></dc:creator><pubDate>Mon, 02 Mar 2015 08:54:47 GMT</pubDate></item><item><title><![CDATA[Reply to variable anzahl von template parametern on Mon, 02 Mar 2015 09:05:23 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich bin kein Profi in Templates und vorallem nicht in Variadic templates, aber ja, das geht. Vieleicht hilft dir das weiter: <a href="http://www.cplusplus.com/articles/EhvU7k9E/" rel="nofollow">http://www.cplusplus.com/articles/EhvU7k9E/</a><br />
oder das hier (perfect forwarding mit variadic templates): <a href="http://stackoverflow.com/questions/6486432/variadic-template-templates-and-perfect-forwarding" rel="nofollow">http://stackoverflow.com/questions/6486432/variadic-template-templates-and-perfect-forwarding</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2444894</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2444894</guid><dc:creator><![CDATA[tkausl]]></dc:creator><pubDate>Mon, 02 Mar 2015 09:05:23 GMT</pubDate></item><item><title><![CDATA[Reply to variable anzahl von template parametern on Mon, 02 Mar 2015 11:18:55 GMT]]></title><description><![CDATA[<p>Was ist denn array für ein Typ und wieso kann das beliebig viele Parameter nehmen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2444902</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2444902</guid><dc:creator><![CDATA[Jodocus]]></dc:creator><pubDate>Mon, 02 Mar 2015 11:18:55 GMT</pubDate></item><item><title><![CDATA[Reply to variable anzahl von template parametern on Mon, 02 Mar 2015 17:32:00 GMT]]></title><description><![CDATA[<p>Schon ...</p>
<pre><code>template&lt; typename T, std::size_t ... &gt; struct array_t;

template&lt; typename T, std::size_t dimension &gt;
struct array_t&lt; T, dimension &gt;
{
	typedef T data_t[ dimension ];
	data_t data;
	T &amp; operator[]( std::size_t index ) { return data[ index ]; }

};

template&lt; typename T, std::size_t dimension, std::size_t ... dimensions &gt;
struct array_t&lt; T, dimension, dimensions ... &gt;
{
	typedef typename array_t&lt; T, dimensions ... &gt;::data_t dimension_minus_one_data_t;
	typedef dimension_minus_one_data_t data_t[ dimension ];
	data_t data;
	dimension_minus_one_data_t &amp; operator[]( std::size_t index ) { return data[ index ]; }
};
</code></pre>
<p>aber warum?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2444938</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2444938</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Mon, 02 Mar 2015 17:32:00 GMT</pubDate></item></channel></rss>