<?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[Arumentenliste für boost::format]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe bisher für Stringformatierung meistens vsprintf verwendet. Dort kann ich pratischerweise gleich die gesamte Argumentenliste als Argument für die Funktion mitgeben. Nun möchte ich auf Boost::format umsteigen, allerdings wirft er mir eine Exception (too_few_args). Wie kann ich diese Argumentenliste auch dafür nutzbar machen?</p>
<p>Beispiel:</p>
<pre><code class="language-cpp">void Format (char *strFormat, ...)
{
    va_list argptr;

    va_start (argptr, strFormat);
    boost::format b_str (boost::format (strFormat) % argptr);
    va_end (argptr);

    std::string strBla = b_str.str();    // exception
}

main ()
{
    Format (&quot;%s %d&quot;, &quot;Hallo&quot;, 5);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/196820/arumentenliste-für-boost-format</link><generator>RSS for Node</generator><lastBuildDate>Wed, 30 Sep 2026 19:29:16 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/196820.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 03 Nov 2007 11:56:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Arumentenliste für boost::format on Sat, 03 Nov 2007 11:56:37 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe bisher für Stringformatierung meistens vsprintf verwendet. Dort kann ich pratischerweise gleich die gesamte Argumentenliste als Argument für die Funktion mitgeben. Nun möchte ich auf Boost::format umsteigen, allerdings wirft er mir eine Exception (too_few_args). Wie kann ich diese Argumentenliste auch dafür nutzbar machen?</p>
<p>Beispiel:</p>
<pre><code class="language-cpp">void Format (char *strFormat, ...)
{
    va_list argptr;

    va_start (argptr, strFormat);
    boost::format b_str (boost::format (strFormat) % argptr);
    va_end (argptr);

    std::string strBla = b_str.str();    // exception
}

main ()
{
    Format (&quot;%s %d&quot;, &quot;Hallo&quot;, 5);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1396943</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1396943</guid><dc:creator><![CDATA[yogle]]></dc:creator><pubDate>Sat, 03 Nov 2007 11:56:37 GMT</pubDate></item><item><title><![CDATA[Reply to Arumentenliste für boost::format on Sat, 03 Nov 2007 17:49:21 GMT]]></title><description><![CDATA[<p>Hat den gar niemand eine Idee? So etwas wie boost::vformat habe ich nicht gefunden...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1397128</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397128</guid><dc:creator><![CDATA[yogle]]></dc:creator><pubDate>Sat, 03 Nov 2007 17:49:21 GMT</pubDate></item><item><title><![CDATA[Reply to Arumentenliste für boost::format on Sat, 03 Nov 2007 18:20:25 GMT]]></title><description><![CDATA[<p>Das funktioniert so nicht, bei der variablen Argumentliste von Format gehen die Typinformationen verloren. Warum rufst du die boost::format-Funktion nicht direkt auf?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1397140</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397140</guid><dc:creator><![CDATA[Badestrand]]></dc:creator><pubDate>Sat, 03 Nov 2007 18:20:25 GMT</pubDate></item><item><title><![CDATA[Reply to Arumentenliste für boost::format on Sat, 03 Nov 2007 19:11:46 GMT]]></title><description><![CDATA[<p>Badestrand schrieb:</p>
<blockquote>
<p>Das funktioniert so nicht, bei der variablen Argumentliste von Format gehen die Typinformationen verloren.</p>
</blockquote>
<p>Da hast du Recht. Die Exception wird zwar ausgelöst, da er den <em>argptr</em> als ein Argument ansieht und es dadurch natürlich zuwenig (falsche) Argumente gibt. Aber rein vom Prinzip her geht es wie du schon sagtest nicht.</p>
<p>Badestrand schrieb:</p>
<blockquote>
<p>Warum rufst du die boost::format-Funktion nicht direkt auf?</p>
</blockquote>
<p>Das war natürlich nur ein Beispiel. Bei mir müsste ich für jeden einzelnen Aufruf extra boost::format aufrufen und dann nochmal die Funktion. Naja vll. bleibe ich dann lieber beim C-Style, mal schauen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1397174</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397174</guid><dc:creator><![CDATA[yogle]]></dc:creator><pubDate>Sat, 03 Nov 2007 19:11:46 GMT</pubDate></item><item><title><![CDATA[Reply to Arumentenliste für boost::format on Sat, 03 Nov 2007 20:44:37 GMT]]></title><description><![CDATA[<p>Von der Ellipse solltest du in C++ weiten Abstand halten. Sobald du ein nicht-POD übergibst, wirds undefiniert.<br />
Schau dir doch mal Boost.Preprocessor an. Damit kannst du ähnliches wie Boost.Format realisieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1397215</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397215</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Sat, 03 Nov 2007 20:44:37 GMT</pubDate></item><item><title><![CDATA[Reply to Arumentenliste für boost::format on Sun, 04 Nov 2007 08:51:14 GMT]]></title><description><![CDATA[<p>Wie soll Boost.Preprocessor da helfen? printf eine ist run-time, der Präprozessor compile-time. <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1397327</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397327</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Sun, 04 Nov 2007 08:51:14 GMT</pubDate></item><item><title><![CDATA[Reply to Arumentenliste für boost::format on Sun, 04 Nov 2007 14:58:48 GMT]]></title><description><![CDATA[<p>Man kann mit Boost.Preprocessor Spezialisierungen oder ähnliches für fast beliebige Anzahl von Parametern erstellen. Damit kommt man an das printf-Verhalten schon recht nahe dran.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1397518</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397518</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Sun, 04 Nov 2007 14:58:48 GMT</pubDate></item></channel></rss>