<?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[[ERLEDIGT] template struct]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>ich möchte diese Typedefs:</p>
<pre><code class="language-cpp">typedef std::pair&lt;PANO_UINT,UTM&gt; UTM_PAIR ;
typedef std::map&lt;PANO_UINT,UTM&gt;::iterator UTM_ITERATOR;
typedef std::map&lt;PANO_UINT,UTM&gt;::const_iterator UTM_CONST_ITERATOR;
typedef std::pair&lt;std::map&lt;PANO_UINT,UTM&gt;::iterator,bool&gt; UTM_BOOL_ITERATOR;

typedef std::pair&lt;PANO_UINT,Knot&gt; KNOT_PAIR ;
typedef std::map&lt;PANO_UINT,Knot&gt;::iterator KNOT_ITERATOR;
typedef std::map&lt;PANO_UINT,Knot&gt;::const_iterator KNOT_CONST_ITERATOR;
typedef std::pair&lt;std::map&lt;PANO_UINT,Knot&gt;::iterator,bool&gt; KNOT_BOOL_ITERATOR;

typedef std::pair&lt;PANO_UINT,Edge&gt; EDGE_PAIR ;
typedef std::map&lt;PANO_UINT,Edge&gt;::iterator EDGE_ITERATOR;
typedef std::map&lt;PANO_UINT,Edge&gt;::const_iterator EDGE_CONST_ITERATOR;
typedef std::pair&lt;std::map&lt;PANO_UINT,Edge&gt;::iterator,bool&gt; EDGE_BOOL_ITERATOR;

typedef std::pair&lt;PANO_UINT,Face&gt; FACE_PAIR ;
typedef std::map&lt;PANO_UINT,Face&gt;::iterator FACE_ITERATOR;
typedef std::pair&lt;std::map&lt;PANO_UINT,Face&gt;::iterator,bool&gt; FACE_BOOL_ITERATOR;
</code></pre>
<p>durch ein struct template ersetzen:</p>
<pre><code class="language-cpp">template&lt;typename T&gt; struct topology { };

template&lt;&gt; struct
topology&lt;typename class T&gt; { 

	typedef std::pair&lt;PANO_UINT,T&gt; pair;
	typedef std::map&lt;PANO_UINT,T&gt;::iterator it;
	typedef std::map&lt;PANO_UINT,T&gt;::const_iterator const_it;
	typedef std::pair&lt;std::map&lt;PANO_UINT,T&gt;::iterator,bool&gt; bool_it;

};
</code></pre>
<p>Dieser Teil scheint mir richtig zu sein. Jetzt habe ich probleme dieses template aus einer Funktion aus aufzurufen.</p>
<p>Wie erstelle ich folgende Variable mit dem template?</p>
<pre><code class="language-cpp">UTM_BOOL_ITERATOR utmboolit;
</code></pre>
<p>Ich dachte eigentlich an</p>
<pre><code class="language-cpp">typedef topology&lt;UTM&gt;:: bool_it utmboolit;
</code></pre>
<p>Klappt aber nicht. Wäre dankbar wenn jemand die richtige Syntax posten würde.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/269177/erledigt-template-struct</link><generator>RSS for Node</generator><lastBuildDate>Mon, 31 Aug 2026 10:00:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/269177.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 20 Jun 2010 13:29:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [ERLEDIGT] template struct on Sun, 20 Jun 2010 14:27:38 GMT]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>ich möchte diese Typedefs:</p>
<pre><code class="language-cpp">typedef std::pair&lt;PANO_UINT,UTM&gt; UTM_PAIR ;
typedef std::map&lt;PANO_UINT,UTM&gt;::iterator UTM_ITERATOR;
typedef std::map&lt;PANO_UINT,UTM&gt;::const_iterator UTM_CONST_ITERATOR;
typedef std::pair&lt;std::map&lt;PANO_UINT,UTM&gt;::iterator,bool&gt; UTM_BOOL_ITERATOR;

typedef std::pair&lt;PANO_UINT,Knot&gt; KNOT_PAIR ;
typedef std::map&lt;PANO_UINT,Knot&gt;::iterator KNOT_ITERATOR;
typedef std::map&lt;PANO_UINT,Knot&gt;::const_iterator KNOT_CONST_ITERATOR;
typedef std::pair&lt;std::map&lt;PANO_UINT,Knot&gt;::iterator,bool&gt; KNOT_BOOL_ITERATOR;

typedef std::pair&lt;PANO_UINT,Edge&gt; EDGE_PAIR ;
typedef std::map&lt;PANO_UINT,Edge&gt;::iterator EDGE_ITERATOR;
typedef std::map&lt;PANO_UINT,Edge&gt;::const_iterator EDGE_CONST_ITERATOR;
typedef std::pair&lt;std::map&lt;PANO_UINT,Edge&gt;::iterator,bool&gt; EDGE_BOOL_ITERATOR;

typedef std::pair&lt;PANO_UINT,Face&gt; FACE_PAIR ;
typedef std::map&lt;PANO_UINT,Face&gt;::iterator FACE_ITERATOR;
typedef std::pair&lt;std::map&lt;PANO_UINT,Face&gt;::iterator,bool&gt; FACE_BOOL_ITERATOR;
</code></pre>
<p>durch ein struct template ersetzen:</p>
<pre><code class="language-cpp">template&lt;typename T&gt; struct topology { };

template&lt;&gt; struct
topology&lt;typename class T&gt; { 

	typedef std::pair&lt;PANO_UINT,T&gt; pair;
	typedef std::map&lt;PANO_UINT,T&gt;::iterator it;
	typedef std::map&lt;PANO_UINT,T&gt;::const_iterator const_it;
	typedef std::pair&lt;std::map&lt;PANO_UINT,T&gt;::iterator,bool&gt; bool_it;

};
</code></pre>
<p>Dieser Teil scheint mir richtig zu sein. Jetzt habe ich probleme dieses template aus einer Funktion aus aufzurufen.</p>
<p>Wie erstelle ich folgende Variable mit dem template?</p>
<pre><code class="language-cpp">UTM_BOOL_ITERATOR utmboolit;
</code></pre>
<p>Ich dachte eigentlich an</p>
<pre><code class="language-cpp">typedef topology&lt;UTM&gt;:: bool_it utmboolit;
</code></pre>
<p>Klappt aber nicht. Wäre dankbar wenn jemand die richtige Syntax posten würde.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1915092</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1915092</guid><dc:creator><![CDATA[darkfate]]></dc:creator><pubDate>Sun, 20 Jun 2010 14:27:38 GMT</pubDate></item><item><title><![CDATA[Reply to [ERLEDIGT] template struct on Sun, 20 Jun 2010 13:34:31 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">template&lt;typename T&gt; 
struct topology 
{ 
    typedef std::pair&lt;int,T&gt; pair;
    typedef typename std::map&lt;int,T&gt;::iterator it;
    typedef typename std::map&lt;int,T&gt;::const_iterator const_it;
    typedef std::pair&lt;it, bool&gt; bool_it;

}; 

int main(int argc, char* argv[])
{
	using namespace std;
	typedef int UTM ;
	typedef topology&lt;UTM&gt;::bool_it utmboolit;

        return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1915099</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1915099</guid><dc:creator><![CDATA[brotbernd]]></dc:creator><pubDate>Sun, 20 Jun 2010 13:34:31 GMT</pubDate></item><item><title><![CDATA[Reply to [ERLEDIGT] template struct on Sun, 20 Jun 2010 13:38:42 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">topology&lt;UTM&gt;::bool_it utmboolit;
</code></pre>
<p>(ohne <code>typdef</code> )</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1915100</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1915100</guid><dc:creator><![CDATA[ipsec]]></dc:creator><pubDate>Sun, 20 Jun 2010 13:38:42 GMT</pubDate></item><item><title><![CDATA[Reply to [ERLEDIGT] template struct on Sun, 20 Jun 2010 13:43:22 GMT]]></title><description><![CDATA[<p>ipsec schrieb:</p>
<blockquote>
<pre><code class="language-cpp">topology&lt;UTM&gt;::bool_it utmboolit;
</code></pre>
<p>(ohne <code>typdef</code> )</p>
</blockquote>
<p>brotbernd schrieb:</p>
<blockquote>
<p>...</p>
</blockquote>
<p>Klappt leider beides nicht.</p>
<p>bool_it is not a member of 'topology&lt;T&gt;'</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1915101</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1915101</guid><dc:creator><![CDATA[darkfate]]></dc:creator><pubDate>Sun, 20 Jun 2010 13:43:22 GMT</pubDate></item><item><title><![CDATA[Reply to [ERLEDIGT] template struct on Sun, 20 Jun 2010 13:59:16 GMT]]></title><description><![CDATA[<p>Sieht so aus, als ob bei Dir ein paar <code>typename</code> s fehlen.</p>
<p>Ich würde Dir auch von Deinen All-Caps-Bezeichnern abraten. Bezeichner bestehend nur aus Großbuchstaben werden typischerweise nur für Makros verwendet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1915105</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1915105</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Sun, 20 Jun 2010 13:59:16 GMT</pubDate></item><item><title><![CDATA[Reply to [ERLEDIGT] template struct on Sun, 20 Jun 2010 14:01:38 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">template&lt;typename T&gt; struct topology{ 

		typedef std::pair&lt;PANO_UINT,T&gt; pair;
		typedef std::map&lt;PANO_UINT,T&gt;::iterator it;
		typedef std::map&lt;PANO_UINT,T&gt;::const_iterator const_it;
		typedef std::pair&lt;it,bool&gt; bool_it;

};
</code></pre>
<p>So scheint es zu funktionieren.</p>
<p>Was hat es mit dieser Vorwärtsdeklaration auf sich? Wann und warum muss diese gemacht werden? Warum muss ich vor manche zeilen nochmal explizit typename hinschreiben? Beispiel:</p>
<pre><code class="language-cpp">#include &lt;map&gt;

using namespace std;

template&lt;typename T&gt; struct topology{
	typedef typename std::pair&lt;int, T&gt; pair;
	typedef typename map&lt;int, T&gt;::iterator it;
	typedef typename map&lt;int, T&gt;::const_iterator const_it;
	typedef std::pair&lt;it, bool&gt; bool_it;

};

int main(int argc, char* argv[])
{

	typedef int UTM ;
	typedef topology&lt;UTM&gt;::bool_it utmboolit;

	return 0;
}
</code></pre>
<p>Wenn ich dort nämlich das typename aus den drei zeilen weglasse, lässt sich das ganze nicht kompilieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1915108</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1915108</guid><dc:creator><![CDATA[darkfate]]></dc:creator><pubDate>Sun, 20 Jun 2010 14:01:38 GMT</pubDate></item><item><title><![CDATA[Reply to [ERLEDIGT] template struct on Sun, 20 Jun 2010 14:11:11 GMT]]></title><description><![CDATA[<p>Das ist doch genau das, was ich vorher gepostet habe!?</p>
<p>Zur Zeit der Deklaration ist T unbekannt. <code>map&lt;int, T&gt;</code> ist von T abhängig (dependent name). Damit der Compiler das in der Typdefinition annimmt, musst du ihm mit <code>typename</code> mitteilen, dass das ein Typ ist.<br />
edit: hmm.. vielleicht kann das jemand besser erklären <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1915111</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1915111</guid><dc:creator><![CDATA[brotbernd]]></dc:creator><pubDate>Sun, 20 Jun 2010 14:11:11 GMT</pubDate></item><item><title><![CDATA[Reply to [ERLEDIGT] template struct on Sun, 20 Jun 2010 14:13:10 GMT]]></title><description><![CDATA[<p>brotbernd schrieb:</p>
<blockquote>
<p>Das ist doch genau das, was ich vorher gepostet habe!?</p>
<p>Zur Zeit der Deklaration ist T unbekannt. <code>map&lt;int, T&gt;</code> ist von T abhängig (dependent name). Damit der Compiler das in der Typdefinition annimmt, musst du ihm mit <code>typename</code> mitteilen, dass das ein Typ ist.<br />
edit: hmm.. vielleicht kann das jemand besser erklären <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
</blockquote>
<p>Ja stimmt, dann hat wahrscheinlich nur diese Vorwärtsdeklaration { }; gestört.<br />
Wofür braucht man sie überhaupt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1915112</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1915112</guid><dc:creator><![CDATA[darkfate]]></dc:creator><pubDate>Sun, 20 Jun 2010 14:13:10 GMT</pubDate></item><item><title><![CDATA[Reply to [ERLEDIGT] template struct on Sun, 20 Jun 2010 14:23:32 GMT]]></title><description><![CDATA[<p><code>{ };</code> ist keine Deklaration sondern Definition. Was du da hattest sieht ein bischen aus wie eine Spezialisierung.</p>
<pre><code class="language-cpp">template&lt;typename T&gt; struct topology { };

template&lt;&gt; struct
topology&lt;int&gt; {
    typedef std::pair&lt;PANO_UINT,int&gt; pair;
    typedef std::map&lt;PANO_UINT,int&gt;::iterator it;
    typedef std::map&lt;PANO_UINT,int&gt;::const_iterator const_it;
    typedef std::pair&lt;std::map&lt;PANO_UINT,int&gt;::iterator,bool&gt; bool_it;
};
</code></pre>
<p>Damit ist der ganze kram nur für topology&lt;int&gt; definiert. Für alle anderen T ist topology leer.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1915116</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1915116</guid><dc:creator><![CDATA[brotbernd]]></dc:creator><pubDate>Sun, 20 Jun 2010 14:23:32 GMT</pubDate></item><item><title><![CDATA[Reply to [ERLEDIGT] template struct on Sun, 20 Jun 2010 14:27:26 GMT]]></title><description><![CDATA[<p>Super, danke für die schnellen Antworten an alle!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1915118</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1915118</guid><dc:creator><![CDATA[darkfate]]></dc:creator><pubDate>Sun, 20 Jun 2010 14:27:26 GMT</pubDate></item></channel></rss>