<?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[Explizite Spezialisierung innerhalb einer parametrisierten Struktur]]></title><description><![CDATA[<p>Hallo,</p>
<p>wie gestern bin ich weiter am testen/spielen mit der Spezialisierung von Klassen/Strukturen und mache folgende Erfahrung. Dieses ist kompilierbar und ausführbar:</p>
<pre><code class="language-cpp">template
&lt;
	int I,
	int J,
	int K
&gt;
struct foo
{
	public:

	private:
		int temp;

		template
		&lt;
			bool foo_me,
			int O
		&gt;
		struct internal_foo;

		template
		&lt;
			int O
		&gt;
		struct internal_foo&lt;true, O&gt;
		{};

		template
		&lt;
			int O
		&gt;
		struct internal_foo&lt;false, O&gt;
		{};
};
</code></pre>
<p>Wogegen dieses nicht ausführbar ist:</p>
<pre><code class="language-cpp">template
&lt;
	int I,
	int J,
	int K
&gt;
struct foo
{
	public:

	private:
		int temp;

		template
		&lt;
			bool foo_me
		&gt;
		struct internal_foo;

		template
		&lt;
		&gt;
		struct internal_foo&lt;true&gt;
		{};

		template
		&lt;
		&gt;
		struct internal_foo&lt;false&gt;
		{};
};
</code></pre>
<p>Zweimal kommt dieser Compiler-Fehler:</p>
<pre><code class="language-cpp">../src/foo3.h:32: error: invalid explicit specialization before '&gt;' token
../src/foo3.h:32: error: explicit specialization in non-namespace scope 'struct foo&lt;I, J, K&gt;'
../src/foo3.h:32: error: enclosing class templates are not explicitly specialized
../src/foo3.h:33: error: template parameters not used in partial specialization:
../src/foo3.h:33: error:         'I'
../src/foo3.h:33: error:         'J'
../src/foo3.h:33: error:         'K'
</code></pre>
<p>Zu meiner Schande muss ich gestehen, dass mir nun nicht klar ist, wie ich dieses richten kann bzw. wie I,J und K genutzt werden sollen.</p>
<p>Könnt ihr mir vielleicht weiter helfen?</p>
<p>Viele Grüße<br />
MM</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/253097/explizite-spezialisierung-innerhalb-einer-parametrisierten-struktur</link><generator>RSS for Node</generator><lastBuildDate>Mon, 14 Sep 2026 02:10:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/253097.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 28 Oct 2009 15:21:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Explizite Spezialisierung innerhalb einer parametrisierten Struktur on Wed, 28 Oct 2009 15:21:37 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>wie gestern bin ich weiter am testen/spielen mit der Spezialisierung von Klassen/Strukturen und mache folgende Erfahrung. Dieses ist kompilierbar und ausführbar:</p>
<pre><code class="language-cpp">template
&lt;
	int I,
	int J,
	int K
&gt;
struct foo
{
	public:

	private:
		int temp;

		template
		&lt;
			bool foo_me,
			int O
		&gt;
		struct internal_foo;

		template
		&lt;
			int O
		&gt;
		struct internal_foo&lt;true, O&gt;
		{};

		template
		&lt;
			int O
		&gt;
		struct internal_foo&lt;false, O&gt;
		{};
};
</code></pre>
<p>Wogegen dieses nicht ausführbar ist:</p>
<pre><code class="language-cpp">template
&lt;
	int I,
	int J,
	int K
&gt;
struct foo
{
	public:

	private:
		int temp;

		template
		&lt;
			bool foo_me
		&gt;
		struct internal_foo;

		template
		&lt;
		&gt;
		struct internal_foo&lt;true&gt;
		{};

		template
		&lt;
		&gt;
		struct internal_foo&lt;false&gt;
		{};
};
</code></pre>
<p>Zweimal kommt dieser Compiler-Fehler:</p>
<pre><code class="language-cpp">../src/foo3.h:32: error: invalid explicit specialization before '&gt;' token
../src/foo3.h:32: error: explicit specialization in non-namespace scope 'struct foo&lt;I, J, K&gt;'
../src/foo3.h:32: error: enclosing class templates are not explicitly specialized
../src/foo3.h:33: error: template parameters not used in partial specialization:
../src/foo3.h:33: error:         'I'
../src/foo3.h:33: error:         'J'
../src/foo3.h:33: error:         'K'
</code></pre>
<p>Zu meiner Schande muss ich gestehen, dass mir nun nicht klar ist, wie ich dieses richten kann bzw. wie I,J und K genutzt werden sollen.</p>
<p>Könnt ihr mir vielleicht weiter helfen?</p>
<p>Viele Grüße<br />
MM</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1799757</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1799757</guid><dc:creator><![CDATA[MrMilk]]></dc:creator><pubDate>Wed, 28 Oct 2009 15:21:37 GMT</pubDate></item><item><title><![CDATA[Reply to Explizite Spezialisierung innerhalb einer parametrisierten Struktur on Wed, 28 Oct 2009 15:52:41 GMT]]></title><description><![CDATA[<p>C++ Standard schrieb:</p>
<blockquote>
<p><strong>14.7.3(1)</strong>: An explicit specialization shall be declared in the namespace of which the template is a member, or, for member templates,<br />
in the namespace of which the enclosing class or enclosing class template is a member. An explicit specialization<br />
of a member function, member class or static data member of a class template shall be declared in the namespace of<br />
which the class template is a member. Such a declaration may also be a definition. If the declaration is not a definition,<br />
the specialization may be defined later.</p>
</blockquote>
<p>Sprich: Das ist verboten, da du die Spezialisierung im falschen Scope machst. Da es sich ohnehin nur um sinnlose Spielerei handelt, bin ich nicht sehr motiviert, eine Alternative zu suchen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1799782</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1799782</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 28 Oct 2009 15:52:41 GMT</pubDate></item><item><title><![CDATA[Reply to Explizite Spezialisierung innerhalb einer parametrisierten Struktur on Wed, 28 Oct 2009 16:22:32 GMT]]></title><description><![CDATA[<p>Hey SeppJ,</p>
<p>danke für die Antwort. Kannst du mir kurz sagen ob dieses einen Lösung ist die akzeptabel ist oder ehr als Fusch bezweichnet werden kann:</p>
<pre><code class="language-cpp">struct foo
{
	public:

	private:
		int temp;

		template
		&lt;
			bool foo_me,
			int dummy = 0
		&gt;
		struct internal_foo;

		template
		&lt;
			int dummy
		&gt;
		struct internal_foo&lt;true, dummy&gt;
		{};

		template
		&lt;
			int dummy
		&gt;
		struct internal_foo&lt;false, dummy&gt;
		{};
};
</code></pre>
<p>Viele Grüße<br />
MM</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1799806</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1799806</guid><dc:creator><![CDATA[MrMilk]]></dc:creator><pubDate>Wed, 28 Oct 2009 16:22:32 GMT</pubDate></item></channel></rss>