<?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[Warning: there are no arguments to &#96;setw&#x27; that depend on a template parameter,...]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich bekomme bei meinem G++ (aus CodeBlocks) folgende Warnung (bzw. Fehlermeldung)</p>
<blockquote>
<p>warning: there are no arguments to `setw' that depend on a template parameter, so a declaration of `setw' must be available</p>
</blockquote>
<p>Das bei folgenden Code</p>
<pre><code class="language-cpp">template &lt;class T&gt;
std::string val2string(const T val, const std::size_t width, const char fillchar) {
    std::stringstream strm;
    strm.fill(fillchar);
    strm &lt;&lt; setw(width) &lt;&lt; val;
    return strm.str();
}
</code></pre>
<p>Könnte mir einer sagen was das bedeutet.<br />
Ich habe zur Zeit durch Angabe von -fpermissive aus dem Fehler eine Warnung gemacht. So richtig gut finde ich das aber nicht.</p>
<p>Ciao</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/128680/warning-there-are-no-arguments-to-setw-that-depend-on-a-template-parameter</link><generator>RSS for Node</generator><lastBuildDate>Tue, 25 Aug 2026 20:14:14 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/128680.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 06 Dec 2005 10:23:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Warning: there are no arguments to &#96;setw&#x27; that depend on a template parameter,... on Tue, 06 Dec 2005 10:23:30 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich bekomme bei meinem G++ (aus CodeBlocks) folgende Warnung (bzw. Fehlermeldung)</p>
<blockquote>
<p>warning: there are no arguments to `setw' that depend on a template parameter, so a declaration of `setw' must be available</p>
</blockquote>
<p>Das bei folgenden Code</p>
<pre><code class="language-cpp">template &lt;class T&gt;
std::string val2string(const T val, const std::size_t width, const char fillchar) {
    std::stringstream strm;
    strm.fill(fillchar);
    strm &lt;&lt; setw(width) &lt;&lt; val;
    return strm.str();
}
</code></pre>
<p>Könnte mir einer sagen was das bedeutet.<br />
Ich habe zur Zeit durch Angabe von -fpermissive aus dem Fehler eine Warnung gemacht. So richtig gut finde ich das aber nicht.</p>
<p>Ciao</p>
]]></description><link>https://www.c-plusplus.net/forum/post/935573</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/935573</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Tue, 06 Dec 2005 10:23:30 GMT</pubDate></item><item><title><![CDATA[Reply to Warning: there are no arguments to &#96;setw&#x27; that depend on a template parameter,... on Tue, 06 Dec 2005 10:28:38 GMT]]></title><description><![CDATA[<p>Für die parametrisierten Manipulatoren (dazu gehört auch setw) benötigst du den Header &lt;iomanip&gt;.</p>
<p>btw, Wertparameter benötigen kein const, um den Aufrufer zu schützen ;):</p>
<pre><code class="language-cpp">template&lt;typename T&gt;
std::string val2string(const T&amp; val/*Referenz!!*/, size_t width/*size_t ist nicht in std*/,char fillchar)
{
  //...
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/935579</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/935579</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 06 Dec 2005 10:28:38 GMT</pubDate></item><item><title><![CDATA[Reply to Warning: there are no arguments to &#96;setw&#x27; that depend on a template parameter,... on Tue, 06 Dec 2005 11:19:09 GMT]]></title><description><![CDATA[<p>CStoll schrieb:</p>
<blockquote>
<p>btw, Wertparameter benötigen kein const, um den Aufrufer zu schützen <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>
</blockquote>
<p>Hilft aber, vor sich selbst zu schützen, wenn man nicht vorhat, den Wert in der Funktion zu verändern.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/935616</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/935616</guid><dc:creator><![CDATA[7H3 N4C3R]]></dc:creator><pubDate>Tue, 06 Dec 2005 11:19:09 GMT</pubDate></item><item><title><![CDATA[Reply to Warning: there are no arguments to &#96;setw&#x27; that depend on a template parameter,... on Tue, 06 Dec 2005 11:58:33 GMT]]></title><description><![CDATA[<p>Das mit der Referenz auf val und size_t habe ich mal geändert.<br />
Das Einfügen von iomanip plus Hinzufügen von std:: vor setw hat dann geholfen.<br />
Ich hatte zuerst nur iomanip eingefügt und das hat nichts geändert. Da gibt es wohl setw noch einmal woanders.</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/935645</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/935645</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Tue, 06 Dec 2005 11:58:33 GMT</pubDate></item></channel></rss>