<?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[std::string Konstruktor]]></title><description><![CDATA[<p>Hi Leute,</p>
<p>wenn ich einer Funktion einen zusammengesetzten String (std::string) übergeben möchte mache ich das bisher so:</p>
<pre><code class="language-cpp">foo(std::string(&quot;Dies &quot;) + &quot;ist ein &quot; + &quot;zusammengesetzter string.&quot;);
</code></pre>
<p>Der String-Konstruktor zu Beginn sorgt dafür, dass ich den &quot;+&quot;-Operator anwenden kann. Nun würde ich aber gerne den Konstruktor am Anfang los werden, um den Code &quot;schöner&quot; bzw. lesbarer zu machen. Die einzige Lösung die mir einfällt währe ein Makro für den Präprozessor, das einfach &quot;std::string(...) einsetzt:</p>
<pre><code class="language-cpp">foo(S(&quot;Dies &quot;) + &quot;ist ein &quot; + &quot;zusammengesetzter string.&quot;);
</code></pre>
<p>Gibt's da nicht ne schönere Lösung?</p>
<p>Grüße,<br />
lucien</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/150992/std-string-konstruktor</link><generator>RSS for Node</generator><lastBuildDate>Sun, 06 Sep 2026 01:27:55 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/150992.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 22 Jun 2006 07:27:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to std::string Konstruktor on Thu, 22 Jun 2006 07:27:43 GMT]]></title><description><![CDATA[<p>Hi Leute,</p>
<p>wenn ich einer Funktion einen zusammengesetzten String (std::string) übergeben möchte mache ich das bisher so:</p>
<pre><code class="language-cpp">foo(std::string(&quot;Dies &quot;) + &quot;ist ein &quot; + &quot;zusammengesetzter string.&quot;);
</code></pre>
<p>Der String-Konstruktor zu Beginn sorgt dafür, dass ich den &quot;+&quot;-Operator anwenden kann. Nun würde ich aber gerne den Konstruktor am Anfang los werden, um den Code &quot;schöner&quot; bzw. lesbarer zu machen. Die einzige Lösung die mir einfällt währe ein Makro für den Präprozessor, das einfach &quot;std::string(...) einsetzt:</p>
<pre><code class="language-cpp">foo(S(&quot;Dies &quot;) + &quot;ist ein &quot; + &quot;zusammengesetzter string.&quot;);
</code></pre>
<p>Gibt's da nicht ne schönere Lösung?</p>
<p>Grüße,<br />
lucien</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1082668</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1082668</guid><dc:creator><![CDATA[*dev*lucien]]></dc:creator><pubDate>Thu, 22 Jun 2006 07:27:43 GMT</pubDate></item><item><title><![CDATA[Reply to std::string Konstruktor on Thu, 22 Jun 2006 08:07:24 GMT]]></title><description><![CDATA[<p>Wenn du nur mit String-Literalen arbeitest, kannst du die + Zeichen auch weglassen - das fügt der Compiler zu einem einzigen Literal zusammen. Wenn du Literale und std::string Variablen mixen willst, reicht notfalls die richtige Klammerung, damit der Operator anwendbar ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1082704</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1082704</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 22 Jun 2006 08:07:24 GMT</pubDate></item><item><title><![CDATA[Reply to std::string Konstruktor on Thu, 22 Jun 2006 08:35:23 GMT]]></title><description><![CDATA[<p>Danke für den Hinweis den Literalen. Ich hab noch ein wenig rumprobiert und anscheinend hab ich mir da was falsch gemerkt. <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="🙄"
    /><br />
Hast du noch nen schnellen Tip zu string + integer? Stringstreams blähen den Quelltext immer so auf. Eigene Unterklasse schreiben? ...oder hab ich da auch wieder was übersehen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1082726</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1082726</guid><dc:creator><![CDATA[*dev*lucien]]></dc:creator><pubDate>Thu, 22 Jun 2006 08:35:23 GMT</pubDate></item><item><title><![CDATA[Reply to std::string Konstruktor on Thu, 22 Jun 2006 08:49:38 GMT]]></title><description><![CDATA[<p>/dev/lucien schrieb:</p>
<blockquote>
<p>Hast du noch nen schnellen Tip zu string + integer?</p>
</blockquote>
<p>sprintf() oder itoa() (letzteres ist afaik nicht im Standard) wären Alterantivmöglichkeiten zu Stringstreams.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1082737</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1082737</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 22 Jun 2006 08:49:38 GMT</pubDate></item><item><title><![CDATA[Reply to std::string Konstruktor on Thu, 22 Jun 2006 11:43:45 GMT]]></title><description><![CDATA[<p>oder <a href="http://www.boost.org/libs/format/doc/format.html" rel="nofollow">boost::format</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1082854</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1082854</guid><dc:creator><![CDATA[Shade Of Mine]]></dc:creator><pubDate>Thu, 22 Jun 2006 11:43:45 GMT</pubDate></item><item><title><![CDATA[Reply to std::string Konstruktor on Thu, 22 Jun 2006 11:59:14 GMT]]></title><description><![CDATA[<p>oder boost::lexical_cast. Ist glaub ich auch im TR2 drin.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1082874</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1082874</guid><dc:creator><![CDATA[Artchi]]></dc:creator><pubDate>Thu, 22 Jun 2006 11:59:14 GMT</pubDate></item><item><title><![CDATA[Reply to std::string Konstruktor on Thu, 22 Jun 2006 14:19:29 GMT]]></title><description><![CDATA[<p>Wobei der intern auch wieder einen stringstream verwendet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1083016</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1083016</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Thu, 22 Jun 2006 14:19:29 GMT</pubDate></item></channel></rss>