<?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[[gelöst-peinlich][gcc-error] template - friend inline]]></title><description><![CDATA[<p>Folgende Klasse verursacht mit dem gcc 3.4 probleme (cl und icpc10.0 nicht)</p>
<pre><code class="language-cpp">namespace UbKeys
{
   //nested class
   template&lt; typename T1, typename T2 = T1 &gt;
   class Key2 
   {
   public:
      Key2(const T1&amp; t1, const T2&amp; t2) 
         : t1(t1), t2(t2)             { }
      /*==========================================================*/
      Key2&amp; operator=(const Key2&amp; srcKey) 
      {
         if(this == &amp;srcKey ) return *this;
         t1    = srcKey.t1;
         t2    = srcKey.t2;
         return *this;
      }
      /*==========================================================*/
      T1 getT1() const { return t1; }
      T2 getT2() const { return t2; }
      friend inline bool operator&lt;(const Key2&amp; lhsKey,const Key2&amp; rhsKey)  
      {
         if( lhsKey.t1 &lt; rhsKey.t1 ) return true;
         if( lhsKey.t1 &gt; rhsKey.t1 ) return false;
         if( lhsKey.t2 &lt; rhsKey.t2 ) return true;
         return false;
      }
      friend inline bool operator==(const Key2&amp; lhsKey, const Key2&amp; rhsKey)  
      {
         if(lhsKey.t1 != rhsKey.t1 ) return false;
         if(lhsKey.t2 != rhsKey.t2 ) return false;
         return true;
      }
      friend inline bool operator!=(const Key2&amp; lhsKey, const Key2&amp; rhsKey)  
      {
/*L 74*/  return return !(lhsKey == rhsKey); 
      }
      friend inline std::ostream&amp; operator &lt;&lt; (std::ostream&amp; os, const Key2&amp; key) 
      {
         os&lt;&lt;&quot;Key2&lt;&quot;&lt;&lt;typeid(T1)&lt;&lt;&quot;,&quot;&lt;&lt;typeid(T2)&lt;&lt;&quot;&gt;,(&quot;&lt;&lt;key.t1&lt;&lt;&quot;,&quot;&lt;&lt;key.t2&lt;&lt;&quot;)&quot;;
         return os;
      }
   private:
      T1 t1;
      T2 t2;
   };
}
</code></pre>
<p>fehler</p>
<blockquote>
<p>UbKeys.h: In function <code>bool UbKeys::operator!=(const UbKeys::Key2&lt;T1, T2&gt;&amp;,const UbKeys::Key2&lt;T1, T2&gt;&amp;)': L 74: error: expected primary-expression before &quot;return&quot; L 74: error: expected</code>;' before &quot;return&quot;</p>
</blockquote>
<p>liegt es daran, dass der compiler nicht mehr vernuenftig die template parameter zuweisen kann? muss ich die friend inline methode noch mit template... versehen?</p>
<p>und wa sist eine primary expression?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/195263/gelöst-peinlich-gcc-error-template-friend-inline</link><generator>RSS for Node</generator><lastBuildDate>Tue, 29 Sep 2026 22:00:33 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/195263.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 16 Oct 2007 06:50:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [gelöst-peinlich][gcc-error] template - friend inline on Tue, 16 Oct 2007 06:54:25 GMT]]></title><description><![CDATA[<p>Folgende Klasse verursacht mit dem gcc 3.4 probleme (cl und icpc10.0 nicht)</p>
<pre><code class="language-cpp">namespace UbKeys
{
   //nested class
   template&lt; typename T1, typename T2 = T1 &gt;
   class Key2 
   {
   public:
      Key2(const T1&amp; t1, const T2&amp; t2) 
         : t1(t1), t2(t2)             { }
      /*==========================================================*/
      Key2&amp; operator=(const Key2&amp; srcKey) 
      {
         if(this == &amp;srcKey ) return *this;
         t1    = srcKey.t1;
         t2    = srcKey.t2;
         return *this;
      }
      /*==========================================================*/
      T1 getT1() const { return t1; }
      T2 getT2() const { return t2; }
      friend inline bool operator&lt;(const Key2&amp; lhsKey,const Key2&amp; rhsKey)  
      {
         if( lhsKey.t1 &lt; rhsKey.t1 ) return true;
         if( lhsKey.t1 &gt; rhsKey.t1 ) return false;
         if( lhsKey.t2 &lt; rhsKey.t2 ) return true;
         return false;
      }
      friend inline bool operator==(const Key2&amp; lhsKey, const Key2&amp; rhsKey)  
      {
         if(lhsKey.t1 != rhsKey.t1 ) return false;
         if(lhsKey.t2 != rhsKey.t2 ) return false;
         return true;
      }
      friend inline bool operator!=(const Key2&amp; lhsKey, const Key2&amp; rhsKey)  
      {
/*L 74*/  return return !(lhsKey == rhsKey); 
      }
      friend inline std::ostream&amp; operator &lt;&lt; (std::ostream&amp; os, const Key2&amp; key) 
      {
         os&lt;&lt;&quot;Key2&lt;&quot;&lt;&lt;typeid(T1)&lt;&lt;&quot;,&quot;&lt;&lt;typeid(T2)&lt;&lt;&quot;&gt;,(&quot;&lt;&lt;key.t1&lt;&lt;&quot;,&quot;&lt;&lt;key.t2&lt;&lt;&quot;)&quot;;
         return os;
      }
   private:
      T1 t1;
      T2 t2;
   };
}
</code></pre>
<p>fehler</p>
<blockquote>
<p>UbKeys.h: In function <code>bool UbKeys::operator!=(const UbKeys::Key2&lt;T1, T2&gt;&amp;,const UbKeys::Key2&lt;T1, T2&gt;&amp;)': L 74: error: expected primary-expression before &quot;return&quot; L 74: error: expected</code>;' before &quot;return&quot;</p>
</blockquote>
<p>liegt es daran, dass der compiler nicht mehr vernuenftig die template parameter zuweisen kann? muss ich die friend inline methode noch mit template... versehen?</p>
<p>und wa sist eine primary expression?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1386053</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1386053</guid><dc:creator><![CDATA[muffmolch]]></dc:creator><pubDate>Tue, 16 Oct 2007 06:54:25 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst-peinlich][gcc-error] template - friend inline on Tue, 16 Oct 2007 06:51:35 GMT]]></title><description><![CDATA[<p>Versuche zunächst mal, das doppelte &quot;return&quot; zu bereinigen. <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1386055</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1386055</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Tue, 16 Oct 2007 06:51:35 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst-peinlich][gcc-error] template - friend inline on Tue, 16 Oct 2007 06:53:05 GMT]]></title><description><![CDATA[<p>Ich würde sagen, das liegt einfach daran, daß du dort zwei &quot;return&quot; hintereinander geschrieben hast <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1386057</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1386057</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 16 Oct 2007 06:53:05 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst-peinlich][gcc-error] template - friend inline on Tue, 16 Oct 2007 06:54:04 GMT]]></title><description><![CDATA[<p>*lol* verdammt...</p>
<p>das hab ich echt nicht gesehen. das ist mir jetzt aber echt peinlich...</p>
<p>BTW kann man eigentlich auch</p>
<pre><code class="language-cpp">friend inline bool operator!=(const Key2&lt;T1,T2&gt;&amp; lhsKey, const Key2&lt;T1,T2&gt;&amp; rhsKey)
</code></pre>
<p>schreiben? würde das Sinn machen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1386059</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1386059</guid><dc:creator><![CDATA[muffmolch]]></dc:creator><pubDate>Tue, 16 Oct 2007 06:54:04 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst-peinlich][gcc-error] template - friend inline on Tue, 16 Oct 2007 07:02:35 GMT]]></title><description><![CDATA[<p>In der Klassendefinition brauchst du die Template-Parameter deines Typs nicht anzugeben (und afaik würde der Compiler sogar implizit das 'inline' ergänzen), außerhalb der Klasse wäre das 'friend' verboten (und ist btw auch überflüssig, da op!= keine internen Daten benötigt).</p>
<p>PS: In deinem Fall könntest du op&lt; und op== auch als Memberfunktionen anlegen.</p>
<p>PPS: Hast du schon mal von std::pair&lt;&gt; gehört?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1386071</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1386071</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 16 Oct 2007 07:02:35 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst-peinlich][gcc-error] template - friend inline on Tue, 16 Oct 2007 07:04:57 GMT]]></title><description><![CDATA[<p>klar hab ich von pair gehört <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="😉"
    /> nutze sie auch fleissig obwohl ich Tuples bevorzuge.<br />
hier habe ich auch nur UbKey2 aufgelistet... es gibt UbKey2/3/4/5 und da werden pairs unübersichtlich und die tuples bei uns durch die val&lt;1&gt;(tuple) syntax etwas unübersichtlich... dennoch danke für den tipp</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1386077</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1386077</guid><dc:creator><![CDATA[muffmolch]]></dc:creator><pubDate>Tue, 16 Oct 2007 07:04:57 GMT</pubDate></item></channel></rss>