<?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[Template Spezialisierung]]></title><description><![CDATA[<p>Hey,<br />
da ich meine template Klasse anfangs nur mit VC++ entwickelt habe und diese da problemlos kompilierbar war stehe ich jetzt mit einem Intel Compiler oder gcc (beide aktuell) vor Problemen.<br />
Diese fangen mit &quot;explicit specialization in non-namespace scope&quot; an gehen über Klammerfehler und hören bei sehr langen Fehlermeldungen auf.</p>
<p>Der Source:</p>
<p>Dieser besteht zuerst aus einer Tupel ähnlichen Konstruktion zum speichern beliebiger Anzahl an Variablen. Diese ist im ersten Source Block zu finden. Im zweiten Block befindet sich die entsprechende Zugriffsstruktur. Im vollständigen Programm stecken beide Strukturen innerhalb des privaten Bereiches einer äußeren Klasse.</p>
<p>Fallen euch die Problemstellen auf? Hoffe das es sich nur um Kleinigkeiten handelt, da ja VC++2013 problemlos durchläuft.</p>
<p>Grüße Dominik</p>
<pre><code>template&lt;class... TArgs_&gt;
	struct _cell;

	template&lt;&gt;
	struct _cell&lt;&gt;
	{
	public:
		inline const std::string write(char delim, _cell&lt;&gt; c){ return std::string(); }
	};

	template&lt;class TFirst_, class... TArgs_&gt;
	struct _cell&lt;TFirst_, TArgs_...&gt; : _cell&lt;TArgs_...&gt;
	{		
	private:
		template &lt;class T&gt;
		struct deref_str;

		template &lt;class T&gt;
		struct deref_str&lt;T*&gt;
		{
			inline static const T&amp; deref(T* x){ return *x; }
		};		

		template &lt;class T&gt;
		struct deref_str
		{
			inline static const T&amp; deref(T&amp; x){ return x; }
		};	

	public:

		TFirst_ data;

		inline const std::string write(char delim, _cell&lt;TFirst_, TArgs_...&gt; c)
		{
			std::stringstream sstr;			
			sstr &lt;&lt; deref_str&lt;TFirst_&gt;::deref(c.data)  &lt;&lt; delim &lt;&lt; (_cell&lt;TArgs_...&gt;::write(delim, c));
			return sstr.str();
		}

	};
</code></pre>
<p>Zugriffs Struktur:</p>
<pre><code>template&lt;int id_, class... TData_&gt;
	struct access_cell;

	template&lt;class TFirst_, class... TRest_&gt;
	struct access_cell&lt;0, TFirst_, TRest_...&gt;
	{
		typedef TFirst_ DataType;
		typedef _cell&lt;TFirst_, TRest_...&gt; CellType;	
	};

	template &lt;int id_, class TFirst_, class... TRest_&gt;
	struct access_cell&lt;id_, TFirst_, TRest_...&gt;	: public access_cell&lt;id_ - 1, TRest_... &gt;{};

	template&lt;int id&gt;
	using DataType = typename access_cell&lt;id, TArgs...&gt;::DataType; 
	template&lt;int id&gt;
	using CellType = typename access_cell&lt;id, TArgs...&gt;::CellType;
</code></pre>
<p>Zugriffs Befehl :</p>
<pre><code>((CellType&lt;id&gt;&amp;)this-&gt;cell).data
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/324092/template-spezialisierung</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Jul 2026 02:12:48 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/324092.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 03 Mar 2014 00:34:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Template Spezialisierung on Mon, 03 Mar 2014 00:34:39 GMT]]></title><description><![CDATA[<p>Hey,<br />
da ich meine template Klasse anfangs nur mit VC++ entwickelt habe und diese da problemlos kompilierbar war stehe ich jetzt mit einem Intel Compiler oder gcc (beide aktuell) vor Problemen.<br />
Diese fangen mit &quot;explicit specialization in non-namespace scope&quot; an gehen über Klammerfehler und hören bei sehr langen Fehlermeldungen auf.</p>
<p>Der Source:</p>
<p>Dieser besteht zuerst aus einer Tupel ähnlichen Konstruktion zum speichern beliebiger Anzahl an Variablen. Diese ist im ersten Source Block zu finden. Im zweiten Block befindet sich die entsprechende Zugriffsstruktur. Im vollständigen Programm stecken beide Strukturen innerhalb des privaten Bereiches einer äußeren Klasse.</p>
<p>Fallen euch die Problemstellen auf? Hoffe das es sich nur um Kleinigkeiten handelt, da ja VC++2013 problemlos durchläuft.</p>
<p>Grüße Dominik</p>
<pre><code>template&lt;class... TArgs_&gt;
	struct _cell;

	template&lt;&gt;
	struct _cell&lt;&gt;
	{
	public:
		inline const std::string write(char delim, _cell&lt;&gt; c){ return std::string(); }
	};

	template&lt;class TFirst_, class... TArgs_&gt;
	struct _cell&lt;TFirst_, TArgs_...&gt; : _cell&lt;TArgs_...&gt;
	{		
	private:
		template &lt;class T&gt;
		struct deref_str;

		template &lt;class T&gt;
		struct deref_str&lt;T*&gt;
		{
			inline static const T&amp; deref(T* x){ return *x; }
		};		

		template &lt;class T&gt;
		struct deref_str
		{
			inline static const T&amp; deref(T&amp; x){ return x; }
		};	

	public:

		TFirst_ data;

		inline const std::string write(char delim, _cell&lt;TFirst_, TArgs_...&gt; c)
		{
			std::stringstream sstr;			
			sstr &lt;&lt; deref_str&lt;TFirst_&gt;::deref(c.data)  &lt;&lt; delim &lt;&lt; (_cell&lt;TArgs_...&gt;::write(delim, c));
			return sstr.str();
		}

	};
</code></pre>
<p>Zugriffs Struktur:</p>
<pre><code>template&lt;int id_, class... TData_&gt;
	struct access_cell;

	template&lt;class TFirst_, class... TRest_&gt;
	struct access_cell&lt;0, TFirst_, TRest_...&gt;
	{
		typedef TFirst_ DataType;
		typedef _cell&lt;TFirst_, TRest_...&gt; CellType;	
	};

	template &lt;int id_, class TFirst_, class... TRest_&gt;
	struct access_cell&lt;id_, TFirst_, TRest_...&gt;	: public access_cell&lt;id_ - 1, TRest_... &gt;{};

	template&lt;int id&gt;
	using DataType = typename access_cell&lt;id, TArgs...&gt;::DataType; 
	template&lt;int id&gt;
	using CellType = typename access_cell&lt;id, TArgs...&gt;::CellType;
</code></pre>
<p>Zugriffs Befehl :</p>
<pre><code>((CellType&lt;id&gt;&amp;)this-&gt;cell).data
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2386183</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2386183</guid><dc:creator><![CDATA[Matyro]]></dc:creator><pubDate>Mon, 03 Mar 2014 00:34:39 GMT</pubDate></item><item><title><![CDATA[Reply to Template Spezialisierung on Mon, 03 Mar 2014 01:03:30 GMT]]></title><description><![CDATA[<pre><code>template &lt;class T&gt;
        struct deref_str;

        template &lt;class T&gt;
        struct deref_str&lt;T*&gt;
        {
            inline static const T&amp; deref(T* x){ return *x; }
        };     

        template &lt;class T&gt;
        struct deref_str
        {
            inline static const T&amp; deref(T&amp; x){ return x; }
        };
</code></pre>
<p>Das ist nicht erlaubt, wie die Fehlermeldung schon sagt (§14.5.5/5). Das muss außerhalb jeglicher Klassen definiert werden.</p>
<blockquote>
<p>da ja VC++2013 problemlos durchläuft.</p>
</blockquote>
<p>VC++ lässt so einiges durchgehen. Mach dir keine Hoffnungen.</p>
<pre><code>inline const std::string write(char delim, _cell&lt;&gt; c){ return std::string(); }
</code></pre>
<p>Du kannst das <code>_cell&lt;&gt;</code> durch <code>_cell</code> ersetzen. Genau wie in der unteren part. Spezialisierungen das <code>_cell&lt;TFirst_, TArgs_...&gt;</code> .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2386184</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2386184</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Mon, 03 Mar 2014 01:03:30 GMT</pubDate></item><item><title><![CDATA[Reply to Template Spezialisierung on Mon, 03 Mar 2014 17:02:46 GMT]]></title><description><![CDATA[<p>So,<br />
ich hab die Klassen schrittweise umgebaut und es Kompiliert erst mal vollständig.<br />
Bis ich den Code</p>
<pre><code>template&lt;int id&gt;
	inline DataType&lt;id&gt; get()
	{
		return ((CellType&lt;id&gt;)this-&gt;cell).data;
	}
</code></pre>
<p>einfüge.</p>
<p>Dann wirft der Intel Compiler die Fehlermeldung:</p>
<blockquote>
<p>error : expected a &quot;&gt;&quot;<br />
1&gt; using DataType = typename access_cell&lt;id, TArgs...&gt;::DataType;<br />
1&gt; ^<br />
1&gt; detected during instantiation of type &quot;minimalBeispiel&lt;TArgs...&gt;::DataType&lt;id&gt;&quot; at line 169</p>
</blockquote>
<p>Die entsprechende Stelle im Source ist die Nachfolgende.<br />
TArgs ist ein Template der umgebenden Klasse. Die grundlegende Spezifikation hat sich zum obigen Beispiel nicht verändert.</p>
<pre><code>template&lt;int id&gt;
	using DataType = typename access_cell&lt;id, TArgs...&gt;::DataType;
	template&lt;int id&gt;
	using CellType = typename access_cell&lt;id, TArgs...&gt;::CellType;
</code></pre>
<p>Grüße Dominik</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2386340</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2386340</guid><dc:creator><![CDATA[Matyro]]></dc:creator><pubDate>Mon, 03 Mar 2014 17:02:46 GMT</pubDate></item></channel></rss>