<?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 und op-überladung]]></title><description><![CDATA[<p>Hallo,</p>
<p>wie geht das nicht:</p>
<pre><code class="language-cpp">template&lt;typename T&gt;
class test
{
 public:

   test(T value):data(value),Style(open){}
   const string&amp; ReturnState() const
      {
       return Names[Style];
      }
   template&lt;typename T&gt;
   friend ostream&amp; operator&lt;&lt;(ostream&amp; os,const test&lt;T&gt;&amp; t);
 private:
  T data;
  static const string Names[2];
  enum styles{open,closed}       Style;
};

template&lt;typename T&gt;
ostream&amp; operator&lt;&lt;(ostream&amp; os,const test&lt;T&gt;&amp; t)
{
 os&lt;&lt;t.Names[t.Style]&lt;&lt;&quot; und: &quot;&lt;&lt;t.data;
 return os;
}
template&lt;typename T&gt;
const string test&lt;T&gt;::Names[2]={&quot;open&quot;,&quot;closed&quot;};

int main(int argc, char* argv[])
{
 test&lt;int&gt; t(19);
 cout&lt;&lt;t;
 getch();       return 0;
}
</code></pre>
<p>Fehler:</p>
<p>[C++ Fehler] Unit1.cpp(47): E2335 Überladene Funktion 'operator ostream &amp; &lt;&lt; &lt;int&gt;(ostream &amp;,const test&lt;int&gt; &amp;)' ist in diesem Kontext mehrdeutig</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/170387/template-und-op-überladung</link><generator>RSS for Node</generator><lastBuildDate>Thu, 17 Sep 2026 01:51:49 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/170387.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 15 Jan 2007 10:58:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Template und op-überladung on Mon, 15 Jan 2007 10:58:24 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>wie geht das nicht:</p>
<pre><code class="language-cpp">template&lt;typename T&gt;
class test
{
 public:

   test(T value):data(value),Style(open){}
   const string&amp; ReturnState() const
      {
       return Names[Style];
      }
   template&lt;typename T&gt;
   friend ostream&amp; operator&lt;&lt;(ostream&amp; os,const test&lt;T&gt;&amp; t);
 private:
  T data;
  static const string Names[2];
  enum styles{open,closed}       Style;
};

template&lt;typename T&gt;
ostream&amp; operator&lt;&lt;(ostream&amp; os,const test&lt;T&gt;&amp; t)
{
 os&lt;&lt;t.Names[t.Style]&lt;&lt;&quot; und: &quot;&lt;&lt;t.data;
 return os;
}
template&lt;typename T&gt;
const string test&lt;T&gt;::Names[2]={&quot;open&quot;,&quot;closed&quot;};

int main(int argc, char* argv[])
{
 test&lt;int&gt; t(19);
 cout&lt;&lt;t;
 getch();       return 0;
}
</code></pre>
<p>Fehler:</p>
<p>[C++ Fehler] Unit1.cpp(47): E2335 Überladene Funktion 'operator ostream &amp; &lt;&lt; &lt;int&gt;(ostream &amp;,const test&lt;int&gt; &amp;)' ist in diesem Kontext mehrdeutig</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1210147</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210147</guid><dc:creator><![CDATA[Foku(s)]]></dc:creator><pubDate>Mon, 15 Jan 2007 10:58:24 GMT</pubDate></item><item><title><![CDATA[Reply to Template und op-überladung on Mon, 15 Jan 2007 11:02:02 GMT]]></title><description><![CDATA[<p>Du brauchst an dieser Stelle kein verschachteltest Template - jede Spezialisierung von test benötigt nur ihren eigenen op&lt;&lt; als Freund und nicht alle Operatoren:</p>
<pre><code class="language-cpp">template&lt;typename T&gt;
class test
{
public:
  friend ostream&amp; operator&lt;&lt;(ostream&amp;, const test&lt;T&gt;&amp;);
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1210150</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210150</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 15 Jan 2007 11:02:02 GMT</pubDate></item><item><title><![CDATA[Reply to Template und op-überladung on Mon, 15 Jan 2007 11:06:41 GMT]]></title><description><![CDATA[<p>code abgeändert in:</p>
<pre><code class="language-cpp">#pragma argsused
template&lt;typename T&gt;
class test
{
 public:

   test(T value):data(value),Style(open){}
   const string&amp; ReturnState() const
      {
       return Names[Style];
      }

   friend ostream&amp; operator&lt;&lt;(ostream&amp; os,const test&lt;T&gt;&amp; t);
 private:
  T data;
  static const string Names[2];
  enum styles{open,closed}       Style;
};

template&lt;typename T&gt;
ostream&amp; operator&lt;&lt;(ostream&amp; os,const test&lt;T&gt;&amp; t)
{
 os&lt;&lt;t.Names[t.Style]&lt;&lt;&quot; und: &quot;&lt;&lt;t.data;
 return os;
}
template&lt;typename T&gt;
const string test&lt;T&gt;::Names[2]={&quot;open&quot;,&quot;closed&quot;};

int main(int argc, char* argv[])
{
 test&lt;int&gt; t(19);
 cout&lt;&lt;t;
 getch();       return 0;
}
</code></pre>
<p>Fehler:</p>
<p>[Linker Fehler] Unresolved external 'operator &lt;&lt;(_STL::basic_ostream&lt;char, _STL::char_traits&lt;char&gt; &gt;&amp;, const test&lt;int&gt;&amp;)' referenced from D:\BCB\PROJECTS\CONST_STRING[]_ENUM\UNIT1.OBJ</p>
<p>hm....was mach ich denn nun noch falsch? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1210153</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210153</guid><dc:creator><![CDATA[Foku(s)]]></dc:creator><pubDate>Mon, 15 Jan 2007 11:06:41 GMT</pubDate></item><item><title><![CDATA[Reply to Template und op-überladung on Mon, 15 Jan 2007 11:12:08 GMT]]></title><description><![CDATA[<p>Vielleicht reicht es ja schon aus, den Operator erst zu deklarieren und dann als Freund anzumelden (zur Not mit einer Forward-Deklaration).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1210154</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210154</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 15 Jan 2007 11:12:08 GMT</pubDate></item><item><title><![CDATA[Reply to Template und op-überladung on Mon, 15 Jan 2007 13:02:43 GMT]]></title><description><![CDATA[<p>kannst du das kurz mla mit code zeigen?<br />
versteh das nicht ganz!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1210232</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210232</guid><dc:creator><![CDATA[Foku(s)]]></dc:creator><pubDate>Mon, 15 Jan 2007 13:02:43 GMT</pubDate></item><item><title><![CDATA[Reply to Template und op-überladung on Mon, 15 Jan 2007 13:08:32 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">//Forward-Deklaration(en):
template&lt;typename T&gt;
class test;
template&lt;typename T&gt;
ostream&amp; operator&lt;&lt;(ostream&amp;,const test&lt;T&gt;&amp;);

//Klassendefinition:
template&lt;typename T&gt;
class test
{
  ...
  friend ostream&amp; operator&lt;&lt;(ostream&amp;,const test&lt;T&gt;&amp;);//eventuell reicht hier auch 'const test&amp;'
  ...
};

//Operatordefinition:
template&lt;typename T&gt;
ostream&amp; operator&lt;&lt;(ostream&amp; out,const test&lt;T&gt;&amp; obj)
{...}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1210235</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210235</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 15 Jan 2007 13:08:32 GMT</pubDate></item><item><title><![CDATA[Reply to Template und op-überladung on Mon, 15 Jan 2007 13:33:08 GMT]]></title><description><![CDATA[<p>Foku(s) schrieb:</p>
<blockquote>
<pre><code class="language-cpp">#pragma argsused
template&lt;typename T&gt;
class test
{
 public:

   test(T value):data(value),Style(open){}
   const string&amp; ReturnState() const
      {
       return Names[Style];
      }

   friend ostream&amp; operator&lt;&lt;(ostream&amp; os,const test&lt;T&gt;&amp; t);
 private:
  T data;
  static const string Names[2];
  enum styles{open,closed}       Style;
};

template&lt;typename T&gt;
ostream&amp; operator&lt;&lt;(ostream&amp; os,const test&lt;T&gt;&amp; t)
{
 os&lt;&lt;t.Names[t.Style]&lt;&lt;&quot; und: &quot;&lt;&lt;t.data;
 return os;
}
template&lt;typename T&gt;
const string test&lt;T&gt;::Names[2]={&quot;open&quot;,&quot;closed&quot;};
</code></pre>
</blockquote>
<p>Schau mal, wenn dein Compiler deine Template Klasse mit T=int definiert, dann haste du in deiner Klasse ja sowas stehen:</p>
<pre><code class="language-cpp">friend ostream&amp; operator&lt;&lt;(ostream&amp; os,const test&lt;int&gt;&amp; t);
</code></pre>
<p>D.h. du sagst das es eine friend-funktion mit dieser Signatur gibt, aber die gibt es nicht, sondern nur das:</p>
<pre><code class="language-cpp">template&lt;typename T&gt;
ostream&amp; operator&lt;&lt;(ostream&amp; os,const test&lt;T&gt;&amp; t)
{
 os&lt;&lt;t.Names[t.Style]&lt;&lt;&quot; und: &quot;&lt;&lt;t.data;
 return os;
}
</code></pre>
<p>Aber hier spielt das T=int keine Rolle, deswegen musst du deine friend-funktion in der Klasse definieren <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<pre><code class="language-cpp">#pragma argsused
template&lt;typename T&gt;
class test
{
 public:

   test(T value):data(value),Style(open){}
   const string&amp; ReturnState() const
      {
       return Names[Style];
      }

   friend ostream&amp; operator&lt;&lt;(ostream&amp; os,const test&lt;T&gt;&amp; t)
   {
     os&lt;&lt;t.Names[t.Style]&lt;&lt;&quot; und: &quot;&lt;&lt;t.data;
     return os;
   }
 private:
  T data;
  static const string Names[2];
  enum styles{open,closed}       Style;
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1210246</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210246</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Mon, 15 Jan 2007 13:33:08 GMT</pubDate></item><item><title><![CDATA[Reply to Template und op-überladung on Mon, 15 Jan 2007 14:42:02 GMT]]></title><description><![CDATA[<p>also das funktioniert jetzt!</p>
<p>@Freak_Coder: könntest du mir aber bitte erklären warum?<br />
Sollte ich jeden operator so in der klasse definieren?<br />
Mir ist nicht ganz kla, warum er hier außerhalb nicht funktioniert, nur wegen dem int?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1210283</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210283</guid><dc:creator><![CDATA[Foku(s)]]></dc:creator><pubDate>Mon, 15 Jan 2007 14:42:02 GMT</pubDate></item><item><title><![CDATA[Reply to Template und op-überladung on Mon, 15 Jan 2007 15:11:41 GMT]]></title><description><![CDATA[<p>Also...<br />
wäre deine Klasse keine Template Klasse würde das ohne Probleme funktionieren so wie du es vorher hattest:</p>
<pre><code class="language-cpp">class MyClass {
  //...
  friend ostream&amp; operator&lt;&lt;(ostream&amp; stream, const MyClass&amp; obj);
};
</code></pre>
<p>Hier sagst du ja dem Compiler das es irgendwo GENAU diese Funktion gibt, also sucht er nach der Definition und findet diese dann zB weiter unten...</p>
<p>Alles ohne Templates kein Problem da die mit friend bekannt-gemachte Funktion auch tatsächlich definiert ist.</p>
<p>Jetzt aber zu Templates:</p>
<pre><code class="language-cpp">template &lt;class T&gt; class MyClass {
  //...
  friend ostream&amp; operator&lt;&lt;(ostream&amp; stream, const MyClass&lt;T&gt;&amp; obj); 
/*&lt;T&gt; kann auch weggelassen werden, da alle MyClass auto. 
 in Class-MyClass MyClass&lt;T&gt; sind, hier nur zum veranschaulichen*/
};

template&lt;class T&gt;
ostream&amp; operator&lt;&lt;(ostream&amp; stream, const MyClass&lt;T&gt;&amp; obj)
{
  //...
}
</code></pre>
<p>Wenn du jetzt irgendwo schreibst:</p>
<pre><code class="language-cpp">MyClass&lt;int&gt; obj;
</code></pre>
<p>Dann kreiert der Compiler sowas hier:</p>
<pre><code class="language-cpp">class MyClass {
  //...
  friend ostream&amp; operator&lt;&lt;(ostream&amp; stream, const MyClass&lt;int&gt;&amp; obj); 
};

template&lt;class T&gt;
ostream&amp; operator&lt;&lt;(ostream&amp; stream, const MyClass&lt;T&gt;&amp; obj)
{
  //...
}
</code></pre>
<p>Wie du siehst werden die Parameter bei friend aufgelöst und da steht schön das int.</p>
<p>Doch unten bei der Definition von op&lt;&lt; steht immer noch T, denn was hat op&lt;&lt; mit MyClass zu tun ? außer das er friend ist. Nämlich gar nichts, deswegen bleiben die Template-Parameter von op&lt;&lt; unangetastet.</p>
<p>Das Problem kann man also nur lösen indem man op&lt;&lt; als friend deklariert und gleichzeitig auch in der Klasse definiert:</p>
<pre><code class="language-cpp">template &lt;class T&gt; class MyClass {
  //...
  friend ostream&amp; operator&lt;&lt;(ostream&amp; stream, const MyClass&lt;T&gt;&amp; obj)ostream&amp;   
  {
    //...
  }
};
</code></pre>
<p>Jetzt wird da auch bei einer Instanzierung direkt das Template aufgelöst <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>Edit:: Effektiv C++ ( 3. Auflage) gibt es ein Kapitel dazu <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1210312</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210312</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Mon, 15 Jan 2007 15:11:41 GMT</pubDate></item><item><title><![CDATA[Reply to Template und op-überladung on Tue, 16 Jan 2007 02:16:57 GMT]]></title><description><![CDATA[<p>Freak_Coders Beitrag ist soweit richtig, aber die Begründung bleibt - für mich - etwas neblig. Auch das angesprochene Kapitel in EffC++ könnte meiner Ansicht nach in dieser Hinsicht klarer sein.</p>
<p>Foku(s) schrieb:</p>
<blockquote>
<pre><code class="language-cpp">template&lt;typename T&gt;
class test
{
...
   template&lt;typename T&gt;
   friend ostream&amp; operator&lt;&lt;(ostream&amp; os,const test&lt;T&gt;&amp; t);
};
</code></pre>
<p>Fehler:</p>
<p>[C++ Fehler] Unit1.cpp(47): E2335 Überladene Funktion 'operator ostream &amp; &lt;&lt; &lt;int&gt;(ostream &amp;,const test&lt;int&gt; &amp;)' ist in diesem Kontext mehrdeutig</p>
</blockquote>
<p>T ist bereits der Parameter des Klassentemplates test und darf nicht im selben Scope redeklariert werden (also auch nicht als Templateparameter des operators&lt;&lt;).<br />
Richtig wäre also</p>
<pre><code class="language-cpp">template&lt;typename T&gt;
class test
{
...
   template&lt;typename U&gt;
   friend ostream&amp; operator&lt;&lt;(ostream&amp; os,const test&lt;U&gt;&amp; t);
...
};

template&lt;typename T&gt;
ostream&amp; operator&lt;&lt;(ostream&amp; os,const test&lt;T&gt;&amp; t)
{
...
</code></pre>
<p>Falls dein Compiler oder Linker ein Problem damit hat, ist das kein Problem der Sprache an sich, sondern eines der Umsetzung durch den entsprechenden Compiler - Der Fehlercode lässt auf den Borlandcompiler schließen, welcher nicht gerade für besonders gute Umsetzung des Standards bekannt ist.</p>
<p>Die folgende alternativen Lösungen versuchen ein anderes Problem zu lösen.</p>
<p>CStoll schrieb:</p>
<blockquote>
<p>Du brauchst an dieser Stelle kein verschachteltest Template - jede Spezialisierung von test benötigt nur ihren eigenen op&lt;&lt; als Freund und nicht alle Operatoren:</p>
<pre><code class="language-cpp">template&lt;typename T&gt;
class test
{
public:
friend ostream&amp; operator&lt;&lt;(ostream&amp;, const test&lt;T&gt;&amp;);
};
</code></pre>
</blockquote>
<p>An einem solchen Operator ist im Grunde nichts auszusetzen, wenn da nicht die Schwierigkeiten mit der Definition wären. Dieser Operator ist <em>keine</em> Templatefunktion oder ein Funktionstemplate - dass einer seiner Parameter eine Templateklasse ist, spielt keine Rolle. Allerdings hat jede Instanz des Templates test ihren eigenen friend operator&lt;&lt; und es gibt keine Möglichkeit, diese allgemein außerhalb der Klasse zu definieren, eben weil die Operatoren selbst gewöhnliche Funktionen sind. Man müsste für jede verwendete Instanz eine eigene Definition liefern. Das ist der Grund, warum in diesem Falle die Definition zusammen mit der friend Deklaration erfolgen sollte, wie von Freak_Coder empfohlen.</p>
<p>Foku(s) schrieb:</p>
<blockquote>
<pre><code class="language-cpp">template&lt;typename T&gt;
class test
{
...
   friend ostream&amp; operator&lt;&lt;(ostream&amp; os,const test&lt;T&gt;&amp; t);
...
};

template&lt;typename T&gt;
ostream&amp; operator&lt;&lt;(ostream&amp; os,const test&lt;T&gt;&amp; t)
{
 os&lt;&lt;t.Names[t.Style]&lt;&lt;&quot; und: &quot;&lt;&lt;t.data;
 return os;
}
...
</code></pre>
</blockquote>
<p>Warum das nicht geht, sollte jetzt klar sein. Die friend Deklaration bezieht sich auf eine gewöhnliche Operatorfunktion, die mit dem später deklarierten Template nichts zu tun hat. Allerdings wird diese gewöhnliche Funktion dann bei der Anwendung dem Template vorgezogen, weil beide gleich gut hinsichtlich der Überladungsauflösung sind. Im Übrigen ließe sich der Templateoperator auch nicht instantiieren, eben weil diese Instanzt nicht friend der Klasse ist.</p>
<p>Wir haben jetzt also zwei Möglichkeiten besprochen:<br />
1. Der Operator ist eine Funktionstemplate, und alle Instanzen dieses Templates sind friend jeder Instanz des Klassentemplates<br />
2. Der Operator ist eine gewöhnliche Funktion, dann muss diese (für das Primärtemplate der Klasse) zwingend (wenn wir beliebige Templateparameter zulassen wollen) inline in einer Frienddeklaration definiert werden.<br />
Die 3. Möglichkeit ist, den Operator als Templatefunktion zu definieren, aber nur diejenige Instanz, deren Funktionsparameter zur jeweiligen Instanz des Klassentemplates passt, dort als friend zu deklarieren. Wir beziehen uns also in der friend Deklaration auf eine Spezialisierung des Templates, das setzt eine vorherige Deklaration des Primärtemplates voraus, was wir nicht innerhalb der Klasse tun können (andernfalls hätten wir ja wieder Fall 1). Das wiederum setzt voraus, dass wir das Klassentemplate vor der Deklaration des Operators deklarieren. also</p>
<pre><code class="language-cpp">template&lt;typename T&gt;
class test;
template&lt;typename T&gt;
ostream&amp; operator&lt;&lt;(ostream&amp;,const test&lt;T&gt;&amp;); // Hier Bezug auf das Template test, daher vorherige Deklaration von test nötig

template&lt;typename T&gt;
class test
{
...
// jetzt Bezug auf eine Spezialisierung von operator&lt;&lt;
  friend ostream&amp; operator&lt;&lt; &lt;T&gt;(ostream&amp;,const test&lt;T&gt;&amp;); // oder nur test, aber das &lt;T&gt; beim Funktionsnamen ist entscheidend!
...
};

template&lt;typename T&gt;
ostream&amp; operator&lt;&lt;(ostream&amp; out,const test&lt;T&gt;&amp; obj)
{...}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1210532</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210532</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Tue, 16 Jan 2007 02:16:57 GMT</pubDate></item><item><title><![CDATA[Reply to Template und op-überladung on Tue, 16 Jan 2007 10:19:20 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>theoretisch müsse es doch auch noch gehen, eine passende Spezialisierung vom operator&lt;&lt;() zur Verfügung zu stellen, oder:</p>
<pre><code class="language-cpp">template &lt;typename T&gt;
class test {
   ...
   friend ostream&amp; operator&lt;&lt; (ostream&amp; stream, A&lt;T&gt; const &amp; a);
};

// Spezialisierung für int
ostream&amp; operator&lt;&lt;(ostream&amp; stream, A&lt;int&gt; const &amp; a) {
 ...
}

int main()
{
   A&lt;int&gt; a;
   cout &lt;&lt; a &lt;&lt; &quot;\n&quot;;
}
</code></pre>
<p>Wenn ich ein A instantiieren will, für das es kein passendes operator&lt;&lt;() gibt, unterbindet das natürlich der Linker...</p>
<p>Ist häßlich und wird auf mit einer &quot;Warning&quot; (klingt allerdings eher nach einer &quot;wollen Sie das wirklich?&quot;-Meldung) bestraft .... aber ist es wirklich unkorrekt ?</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1210569</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210569</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Tue, 16 Jan 2007 10:19:20 GMT</pubDate></item><item><title><![CDATA[Reply to Template und op-überladung on Tue, 16 Jan 2007 11:56:46 GMT]]></title><description><![CDATA[<p>Simon2 schrieb:</p>
<blockquote>
<p>Hi,</p>
<p>theoretisch müsse es doch auch noch gehen, eine passende Spezialisierung vom operator&lt;&lt;() zur Verfügung zu stellen, oder:</p>
</blockquote>
<p>Das kannst du tun (deshalb meine etwas umständliche Einschränkung für Punkt 2 - wenn wir beliebige Templateparameter zulassen wollen). Nur die Wortwahl ist ungünstig. Es handelt sich nicht um eine (zusätzliche) Spezialisierung sondern um eine Überladung.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1210672</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210672</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Tue, 16 Jan 2007 11:56:46 GMT</pubDate></item><item><title><![CDATA[Reply to Template und op-überladung on Tue, 16 Jan 2007 12:10:30 GMT]]></title><description><![CDATA[<p>camper schrieb:</p>
<blockquote>
<p>Simon2 schrieb:</p>
<blockquote>
<p>Hi,</p>
<p>theoretisch müsse es doch auch noch gehen, eine passende Spezialisierung vom operator&lt;&lt;() zur Verfügung zu stellen, oder:</p>
</blockquote>
<p>Das kannst du tun (deshalb meine etwas umständliche Einschränkung für Punkt 2 - wenn wir beliebige Templateparameter zulassen wollen). Nur die Wortwahl ist ungünstig. Es handelt sich nicht um eine (zusätzliche) Spezialisierung sondern um eine Überladung.</p>
</blockquote>
<p>Hmmm, ...*grübel*<br />
... unter &quot;Überladung&quot; verstehe ich die Existenz von mindestens 2 Funktionen mit demselben Namen aber unterschiedlicher Signatur ....<br />
... &quot;Spezialisierung&quot; setzt ein &quot;generaleres template&quot; voraus, ....</p>
<p>=&gt; Du hast also (wie immer <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> ) Recht !</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1210692</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1210692</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Tue, 16 Jan 2007 12:10:30 GMT</pubDate></item></channel></rss>