<?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[Ausgabe verkuerzbar?]]></title><description><![CDATA[<p>Hallo,</p>
<p>kann mir jemand sagen, ob man die Fehlermeldung</p>
<pre><code class="language-cpp">stringstream ss;
ss &lt;&lt; &quot;trying to remove sequence &quot; &lt;&lt; idx &lt;&lt; &quot; of subtype &quot; &lt;&lt; subtype &lt;&lt; &quot; which has &quot; &lt;&lt; seqs_of_target_sub.size() &lt;&lt; &quot; sequences&quot;;
throw ss.str();
</code></pre>
<p>irgendwie verkuerzen kann (hierbei sind idx, subtype und seqs_of_target_sub.size() alles Build-in-Types)?</p>
<p>Mein Problem ist hier, dass man nicht einfach die &lt;&lt; durch + ersetzen kann und das Ganze in einem String speichern.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/246458/ausgabe-verkuerzbar</link><generator>RSS for Node</generator><lastBuildDate>Fri, 18 Sep 2026 01:59:11 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/246458.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 28 Jul 2009 15:33:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ausgabe verkuerzbar? on Tue, 28 Jul 2009 15:34:07 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>kann mir jemand sagen, ob man die Fehlermeldung</p>
<pre><code class="language-cpp">stringstream ss;
ss &lt;&lt; &quot;trying to remove sequence &quot; &lt;&lt; idx &lt;&lt; &quot; of subtype &quot; &lt;&lt; subtype &lt;&lt; &quot; which has &quot; &lt;&lt; seqs_of_target_sub.size() &lt;&lt; &quot; sequences&quot;;
throw ss.str();
</code></pre>
<p>irgendwie verkuerzen kann (hierbei sind idx, subtype und seqs_of_target_sub.size() alles Build-in-Types)?</p>
<p>Mein Problem ist hier, dass man nicht einfach die &lt;&lt; durch + ersetzen kann und das Ganze in einem String speichern.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1751022</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1751022</guid><dc:creator><![CDATA[ingobulla]]></dc:creator><pubDate>Tue, 28 Jul 2009 15:34:07 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabe verkuerzbar? on Tue, 28 Jul 2009 15:35:29 GMT]]></title><description><![CDATA[<p>Mit <code>ss.str();</code> kriegst du ja deinen string.. Wo ist genau das Problem?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1751024</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1751024</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Tue, 28 Jul 2009 15:35:29 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabe verkuerzbar? on Tue, 28 Jul 2009 16:17:44 GMT]]></title><description><![CDATA[<p><a href="http://www.boost.org/doc/libs/1_39_0/libs/format/index.html" rel="nofollow">Boost.Format</a><br />
Oder strukturiere deinen Code über mehrere Zeilen:</p>
<pre><code class="language-cpp">ss &lt;&lt; &quot;trying to remove sequence &quot;
   &lt;&lt; idx
   &lt;&lt; &quot; of subtype &quot;
   &lt;&lt; subtype
   &lt;&lt; &quot; which has &quot;
   &lt;&lt; seqs_of_target_sub.size()
   &lt;&lt; &quot; sequences&quot;;
</code></pre>
<p>Nicht unbedingt kürzer, aber dafür lesbarer.</p>
<p>Im übrigen, das Ersetzen von &lt;&lt; durch + würde die Sache ja nicht wirklich verkürzen. <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: Oder am besten die Idee von BBBB gleich nach meinem Beitrag. Hatte das throw gar nicht gesehen. Man wirft keine Fehlernachrichten, sondern Fehler mit Informationen, woraus man dann Fehlernachrichten erstellen kann.</p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1751052</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1751052</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Tue, 28 Jul 2009 16:17:44 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabe verkuerzbar? on Tue, 28 Jul 2009 16:14:43 GMT]]></title><description><![CDATA[<p>ingobulla schrieb:</p>
<blockquote>
<p>Hallo,</p>
<p>kann mir jemand sagen, ob man die Fehlermeldung</p>
<pre><code class="language-cpp">stringstream ss;
ss &lt;&lt; &quot;trying to remove sequence &quot; &lt;&lt; idx &lt;&lt; &quot; of subtype &quot; &lt;&lt; subtype &lt;&lt; &quot; which has &quot; &lt;&lt; seqs_of_target_sub.size() &lt;&lt; &quot; sequences&quot;;
throw ss.str();
</code></pre>
<p>irgendwie verkuerzen kann (hierbei sind idx, subtype und seqs_of_target_sub.size() alles Build-in-Types)?</p>
<p>Mein Problem ist hier, dass man nicht einfach die &lt;&lt; durch + ersetzen kann und das Ganze in einem String speichern.</p>
</blockquote>
<p>Schreib dir eine vernünftige Exception-Klasse!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1751054</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1751054</guid><dc:creator><![CDATA[BBBB]]></dc:creator><pubDate>Tue, 28 Jul 2009 16:14:43 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabe verkuerzbar? on Tue, 28 Jul 2009 17:13:07 GMT]]></title><description><![CDATA[<p>Woran ich gedacht habe war:</p>
<pre><code class="language-cpp">throw &quot;trying to remove sequence &quot; + idx + &quot; of subtype &quot; + subtype + &quot; which has &quot; + seqs_of_target_sub.size() + &quot; sequences&quot;;
</code></pre>
<p>Das geht so aber ja nicht und ich war mich am fragen, ob es einen Workaround gibt, um es trotzdem als Einzeiler hinzukriegen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1751080</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1751080</guid><dc:creator><![CDATA[ingobulla]]></dc:creator><pubDate>Tue, 28 Jul 2009 17:13:07 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabe verkuerzbar? on Tue, 28 Jul 2009 17:16:21 GMT]]></title><description><![CDATA[<p>ingobulla schrieb:</p>
<blockquote>
<p>Woran ich gedacht habe war:</p>
<pre><code class="language-cpp">throw &quot;trying to remove sequence &quot; + idx + &quot; of subtype &quot; + subtype + &quot; which has &quot; + seqs_of_target_sub.size() + &quot; sequences&quot;;
</code></pre>
<p>Das geht so aber ja nicht und ich war mich am fragen, ob es einen Workaround gibt, um es trotzdem als Einzeiler hinzukriegen.</p>
</blockquote>
<p>Mit Gewalt so?</p>
<pre><code class="language-cpp">throw (stringstream()&lt;&lt; &quot;trying to remove sequence &quot; &lt;&lt; idx &lt;&lt; &quot; of subtype &quot; &lt;&lt; subtype &lt;&lt; &quot; which has &quot; &lt;&lt; seqs_of_target_sub.size() &lt;&lt; &quot; sequences&quot;).str();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1751084</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1751084</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Tue, 28 Jul 2009 17:16:21 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabe verkuerzbar? on Tue, 28 Jul 2009 19:17:44 GMT]]></title><description><![CDATA[<p>ingobulla schrieb:</p>
<blockquote>
<p>Woran ich gedacht habe war:</p>
<pre><code class="language-cpp">throw &quot;trying to remove sequence &quot; + idx + &quot; of subtype &quot; + subtype + &quot; which has &quot; + seqs_of_target_sub.size() + &quot; sequences&quot;;
</code></pre>
<p>Das geht so aber ja nicht und ich war mich am fragen, ob es einen Workaround gibt, um es trotzdem als Einzeiler hinzukriegen.</p>
</blockquote>
<p>Frage: Wozu? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Zudem, wie BBBB es gesagt hat, mach dir eine vernünftige Exceptionklasse. Das Werfen eines Fehlers und das Erstellen einer Fehlermeldung sind zwei verschiedene Dinge. Dort wo man einen Fehler wirft, erstellt man keine Fehlermeldung. Die Fehlermeldung entsteht frühestens dort, wo man den Fehler behandelt.</p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1751150</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1751150</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Tue, 28 Jul 2009 19:17:44 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabe verkuerzbar? on Wed, 29 Jul 2009 08:24:00 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>Mit Gewalt so?</p>
<pre><code class="language-cpp">throw (stringstream()&lt;&lt; &quot;trying to remove sequence &quot; &lt;&lt; idx &lt;&lt; &quot; of subtype &quot; &lt;&lt; subtype &lt;&lt; &quot; which has &quot; &lt;&lt; seqs_of_target_sub.size() &lt;&lt; &quot; sequences&quot;).str();
</code></pre>
</blockquote>
<p>Gewalt ist in dem Fall ok, Groesse und Einsatzzweck des Programms lassen mir die Verwendung von Exceptionn-Klassen in diesem Fall entbehrlich erscheinen.</p>
<p>Allerdings liefert</p>
<pre><code class="language-cpp">throw (stringstream()&lt;&lt; &quot;trying to remove sequence &quot; &lt;&lt; idx &lt;&lt; &quot; of subtype &quot; &lt;&lt; subtype &lt;&lt; &quot; which has &quot; &lt;&lt; seqs_of_target_sub.size() &lt;&lt; &quot; sequences&quot;).str();
</code></pre>
<p>die Fehlermeldung</p>
<pre><code class="language-cpp">SubtypeMap.cpp:169: Fehler: »struct std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;« hat kein Element namens »str«
</code></pre>
<p>und</p>
<pre><code class="language-cpp">throw (stringstream()&lt;&lt; &quot;trying to remove sequence &quot; &lt;&lt; idx &lt;&lt; &quot; of subtype &quot; &lt;&lt; subtype &lt;&lt; &quot; which has &quot; &lt;&lt; seqs_of_target_sub.size() &lt;&lt; &quot; sequences&quot;);
</code></pre>
<p>die Fehlermeldung</p>
<pre><code class="language-cpp">/usr/include/c++/4.3/bits/ios_base.h: In copy constructor »std::basic_ios&lt;char, std::char_traits&lt;char&gt; &gt;::basic_ios(const std::basic_ios&lt;char, std::char_traits&lt;char&gt; &gt;&amp;)«:
/usr/include/c++/4.3/bits/ios_base.h:782: Fehler: »std::ios_base::ios_base(const std::ios_base&amp;)« ist privat
/usr/include/c++/4.3/iosfwd:52: Fehler: in diesem Zusammenhang
/usr/include/c++/4.3/iosfwd: In copy constructor »std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;::basic_ostream(const std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;)«:
/usr/include/c++/4.3/iosfwd:61: Anmerkung: künstlich erzeugte Methode »std::basic_ios&lt;char, std::char_traits&lt;char&gt; &gt;::basic_ios(const std::basic_ios&lt;char, std::char_traits&lt;char&gt; &gt;&amp;)« zuerst hier erfordert 
SubtypeMap.cpp: In static member function »static bool SubtypeMap::remove_sequence(const char&amp;, unsigned int)«:
SubtypeMap.cpp:169: Anmerkung: künstlich erzeugte Methode »std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;::basic_ostream(const std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;)« zuerst hier erfordert
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1751357</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1751357</guid><dc:creator><![CDATA[ingobulla]]></dc:creator><pubDate>Wed, 29 Jul 2009 08:24:00 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabe verkuerzbar? on Wed, 29 Jul 2009 09:02:29 GMT]]></title><description><![CDATA[<p>BBBB schrieb:</p>
<blockquote>
<p>Schreib dir eine vernünftige Exception-Klasse!</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1751389</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1751389</guid><dc:creator><![CDATA[zwutz]]></dc:creator><pubDate>Wed, 29 Jul 2009 09:02:29 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabe verkuerzbar? on Wed, 29 Jul 2009 13:57:07 GMT]]></title><description><![CDATA[<p>vor langer zeit schrieb ich sowas:</p>
<pre><code class="language-cpp">void throw_funny_exception(int idx,char const* suty,int cnt){
	ostringstream oss;
	oss &lt;&lt; &quot;trying to remove sequence &quot; &lt;&lt; 5 &lt;&lt; &quot; of subtype &quot; &lt;&lt; &quot;suty&quot; &lt;&lt; &quot; which has &quot; &lt;&lt; 8 &lt;&lt; &quot; sequences&quot;;
	throw oss.str();
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1751653</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1751653</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Wed, 29 Jul 2009 13:57:07 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabe verkuerzbar? on Wed, 29 Jul 2009 14:15:45 GMT]]></title><description><![CDATA[<p>ingobulla schrieb:</p>
<blockquote>
<p>Allerdings liefert</p>
<pre><code class="language-cpp">throw (stringstream()&lt;&lt; &quot;trying to remove sequence &quot; &lt;&lt; idx &lt;&lt; &quot; of subtype &quot; &lt;&lt; subtype &lt;&lt; &quot; which has &quot; &lt;&lt; seqs_of_target_sub.size() &lt;&lt; &quot; sequences&quot;).str();
</code></pre>
<p>die Fehlermeldung</p>
<pre><code class="language-cpp">SubtypeMap.cpp:169: Fehler: »struct std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;« hat kein Element namens »str«
</code></pre>
</blockquote>
<p>Die op&lt;&lt; liefern eine ostream-Referenz auf den stringstream. ostreams haben aber keine str()-methode. daher musst du dann noch casten:</p>
<pre><code class="language-cpp">throw static_cast&lt;stringstream&amp;&gt;(stringstream()&lt;&lt; &quot;trying to remove sequence &quot; &lt;&lt; idx &lt;&lt; &quot; of subtype &quot; &lt;&lt; subtype &lt;&lt; &quot; which has &quot; &lt;&lt; seqs_of_target_sub.size() &lt;&lt; &quot; sequences&quot;).str();
</code></pre>
<p>*schauder*</p>
<p>Du könntest folgende kleine Klasse nehmen:</p>
<pre><code class="language-cpp">class streamlike_exception : public std::exception
{
public:
  streamlike_exception()
    : osstr() {}
  streamlike_exception (const std::exception&amp; other)
    : osstr(other.what()) {}
  streamlike_exception(std::string const&amp; s) 
    : osstr(s) {}
  streamlike_exception&amp; operator= (const streamlike_exception&amp; that) throw()
  {
    osstr.str(other.osstr.str());
    return *this;
  }
  virtual ~streamlike_exception() {}
  virtual const char* what() const
  {
    return osstr.str().c_str();
  }
  template &lt;typename T&gt;
  streamlike_exception&amp; operator&lt;&lt; (T const&amp; t)
  { osstr &lt;&lt; t; return *this; }
private:
   std::ostringstream osstr;
};

void foo()
{
  throw streamlike_exception(&quot;trying to remove sequence &quot;) &lt;&lt; idx &lt;&lt; &quot; of subtype &quot; &lt;&lt; subtype &lt;&lt; &quot; which has &quot; &lt;&lt; seqs_of_target_sub.size() &lt;&lt; &quot; sequences&quot;;
}
</code></pre>
<p>hat den Vorteil dass es eben eine &quot;richtige&quot; std::exception ist und kein umhergeworfener string <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/1751677</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1751677</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Wed, 29 Jul 2009 14:15:45 GMT</pubDate></item></channel></rss>