<?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[Bestimmten String in std::vector ersetzen]]></title><description><![CDATA[<p>Hallo,</p>
<p>kann mir bitte mal jemand einen Vorschlag geben, wie ich mal schnell ín einem std::vector<a href="std::string" rel="nofollow">std::string</a> einen String mit einem anderen ersetzen kann ? <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>Über std::replace kann ich ja nur Chars ersetzen, ich will aber einen ganzen String:</p>
<pre><code class="language-cpp">vector&lt;wstring&gt; vCfgContent;
strToWrite = L&quot;Standard Scroll Bars (German)&quot;;
wifstream fRead;
fRead.open(strCfgPath.c_str());
if (!fRead.is_open())
{
    GenerateErrorMessage(L&quot;Config bearbeiten&quot;);
    return false;
}
while (getline(fRead, temp))
    vCfgContent.push_back(temp);
fRead.close();
replace(vCfgContent.begin(), vCfgContent.end(), L&quot;Standard Scroll Bars (English)&quot;, strCfgDir);    // So geht das ja nicht !
</code></pre>
<p>Ich habe absolut keine Idee !</p>
<p>Wer kann mir denn auf die Schnelle mal helfen ??</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/241248/bestimmten-string-in-std-vector-ersetzen</link><generator>RSS for Node</generator><lastBuildDate>Mon, 21 Sep 2026 16:24:07 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/241248.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 18 May 2009 09:11:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Bestimmten String in std::vector ersetzen on Mon, 18 May 2009 09:29:29 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>kann mir bitte mal jemand einen Vorschlag geben, wie ich mal schnell ín einem std::vector<a href="std::string" rel="nofollow">std::string</a> einen String mit einem anderen ersetzen kann ? <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>Über std::replace kann ich ja nur Chars ersetzen, ich will aber einen ganzen String:</p>
<pre><code class="language-cpp">vector&lt;wstring&gt; vCfgContent;
strToWrite = L&quot;Standard Scroll Bars (German)&quot;;
wifstream fRead;
fRead.open(strCfgPath.c_str());
if (!fRead.is_open())
{
    GenerateErrorMessage(L&quot;Config bearbeiten&quot;);
    return false;
}
while (getline(fRead, temp))
    vCfgContent.push_back(temp);
fRead.close();
replace(vCfgContent.begin(), vCfgContent.end(), L&quot;Standard Scroll Bars (English)&quot;, strCfgDir);    // So geht das ja nicht !
</code></pre>
<p>Ich habe absolut keine Idee !</p>
<p>Wer kann mir denn auf die Schnelle mal helfen ??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712058</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712058</guid><dc:creator><![CDATA[R3dNeXX]]></dc:creator><pubDate>Mon, 18 May 2009 09:29:29 GMT</pubDate></item><item><title><![CDATA[Reply to Bestimmten String in std::vector ersetzen on Mon, 18 May 2009 09:14:57 GMT]]></title><description><![CDATA[<p>hier ist die fkt dokumentiert und nen bsp dazu findest du hier auch:</p>
<p><a href="http://www.cplusplus.com/reference/algorithm/replace/" rel="nofollow">http://www.cplusplus.com/reference/algorithm/replace/</a></p>
<p>Kannst es ja noch ma versuchen und falls es dann noch immer nich klappen sollte, dich einfach noch ma melden...</p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712060</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712060</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Mon, 18 May 2009 09:14:57 GMT</pubDate></item><item><title><![CDATA[Reply to Bestimmten String in std::vector ersetzen on Mon, 18 May 2009 09:25:01 GMT]]></title><description><![CDATA[<p>R3dNeXX schrieb:</p>
<blockquote>
<pre><code class="language-cpp">replace(vCfgContent.begin(), vCfgContent.end(), &quot;Standard Scroll Bars (English)&quot;, strCfgDir);    // So geht das ja nicht !
</code></pre>
</blockquote>
<ol>
<li>Hast dus ausprobiert?</li>
<li>Was heißt &quot;geht nicht&quot; (Fehlermeldung?)</li>
</ol>
]]></description><link>https://www.c-plusplus.net/forum/post/1712065</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712065</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Mon, 18 May 2009 09:25:01 GMT</pubDate></item><item><title><![CDATA[Reply to Bestimmten String in std::vector ersetzen on Mon, 18 May 2009 09:28:37 GMT]]></title><description><![CDATA[<p>Hm nunja, die Doku hab ich mir angeschaut, werde da aber trotzdem nicht weiter schlau daraus.</p>
<p>Ich kann mit std::replace ja Chars, Int, ... ersetzen, aber kein std::string !<br />
Oder täusche ich mich ?<br />
Gibts da andere Möglichkeiten oder Umwege ?</p>
<p>Denn als Compiler-Error kireg ich mit Angabe von std:.string ja</p>
<p>MSVC schrieb:</p>
<blockquote>
<p>error C2782: 'void std::replace(_FwdIt,_FwdIt,const _Ty &amp;,const _Ty &amp;)' : template parameter '_Ty' is ambiguous</p>
</blockquote>
<p>An den einfachen (?) Dingen scheiterts ! <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="🙄"
    /></p>
<p>PS: Code oben editiert.</p>
<p>EDIT:<br />
Da war jemand schneller ! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /><br />
zu 1.: Ja, habe ich !</p>
<p>Aber gibts vielleicht ne Unicode-Variante davon ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712069</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712069</guid><dc:creator><![CDATA[R3dNeXX]]></dc:creator><pubDate>Mon, 18 May 2009 09:28:37 GMT</pubDate></item><item><title><![CDATA[Reply to Bestimmten String in std::vector ersetzen on Mon, 18 May 2009 09:40:43 GMT]]></title><description><![CDATA[<p>du kannst mit std::replace alles ersetzen was man vergleichen und kopieren kann. Also auch std:.strings.<br />
In dienem Fall ist das problem lediglich, dass replace mit zweimal dem gleichen Typ als Parameter deklariert ist (nämlich dem Templateparameter _Ty), du aber einmal einen wchar_t* und einmal einen wstring lieferst. Er weiß daher nicht ob _Ty jetzt wchar_t* odert wstring sein soll. Zwei Lösungsmöglichkeiten gibts:</p>
<ol>
<li>Du gibst den Templateparameter explizit an: <code>replace&lt;wstring&gt;(/* parameter wie gehabt*/)</code></li>
<li>Du konvertierst den char* in einen wstring, dann ist der Typ eindeutig:<br />
[c]replace(vCfgContent.begin(), vCfgContent.end(), wstring(L&quot;Standard Scroll Bars (English)&quot;), strCfgDir);</li>
</ol>
<p>Ich würd die zweite Möglichkeit bevorzugen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712073</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712073</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Mon, 18 May 2009 09:40:43 GMT</pubDate></item><item><title><![CDATA[Reply to Bestimmten String in std::vector ersetzen on Mon, 18 May 2009 09:53:30 GMT]]></title><description><![CDATA[<p>pumuckl schrieb:</p>
<blockquote>
<p>du kannst mit std::replace alles ersetzen was man vergleichen und kopieren kann. Also auch std:.strings.</p>
</blockquote>
<p>Ok, hätte mich ja auch gewundert ehrlich gesagt.</p>
<p>Perfekt, habe die 2. Möglichkeit benutzt und funktioniert so wie es soll !<br />
Vielen Dank ! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
<p>Hab irgendwie nicht drangedacht, den 2. Parameter in wstring zu casten !<br />
War überzeugt, dass es funzt bei der Angabe des L (Makros ?).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712076</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712076</guid><dc:creator><![CDATA[R3dNeXX]]></dc:creator><pubDate>Mon, 18 May 2009 09:53:30 GMT</pubDate></item><item><title><![CDATA[Reply to Bestimmten String in std::vector ersetzen on Mon, 18 May 2009 09:59:12 GMT]]></title><description><![CDATA[<p>R3dNeXX schrieb:</p>
<blockquote>
<p>War überzeugt, dass es funzt bei der Angabe des L (Makros ?).</p>
</blockquote>
<p>Ist kein Makro, sondern kennzeichnet das Ganze nur als Wstring-Literal (im Vergleich zum normalen String-Literal. Und Literale sind dank C-Historie char* bzw. wchar*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712077</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712077</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Mon, 18 May 2009 09:59:12 GMT</pubDate></item><item><title><![CDATA[Reply to Bestimmten String in std::vector ersetzen on Mon, 18 May 2009 10:01:16 GMT]]></title><description><![CDATA[<p>Ok, war noch ne kleine (versteckte) Frage. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Nochmals vielen Dank !</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712079</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712079</guid><dc:creator><![CDATA[R3dNeXX]]></dc:creator><pubDate>Mon, 18 May 2009 10:01:16 GMT</pubDate></item><item><title><![CDATA[Reply to Bestimmten String in std::vector ersetzen on Mon, 18 May 2009 10:31:02 GMT]]></title><description><![CDATA[<blockquote>
<p>Hab irgendwie nicht drangedacht, den 2. Parameter in wstring zu casten !</p>
</blockquote>
<p>es war der 3. parameter<br />
und es war kein cast sondern lediglich ein aufruf eines konstruktors und damit eine (saubere) konvertierung...</p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712097</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712097</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Mon, 18 May 2009 10:31:02 GMT</pubDate></item><item><title><![CDATA[Reply to Bestimmten String in std::vector ersetzen on Mon, 18 May 2009 11:22:49 GMT]]></title><description><![CDATA[<p>Per Cast würde es doch genauso funktionieren !(?)</p>
<p>Und ich zähle aus Gewohnheit immer von 0 an (in der Programmierung).<br />
Deshalb sagte ich 2.Parameter.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712136</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712136</guid><dc:creator><![CDATA[R3dNeXX]]></dc:creator><pubDate>Mon, 18 May 2009 11:22:49 GMT</pubDate></item><item><title><![CDATA[Reply to Bestimmten String in std::vector ersetzen on Mon, 18 May 2009 11:38:04 GMT]]></title><description><![CDATA[<p>R3dNeXX schrieb:</p>
<blockquote>
<p>Per Cast würde es doch genauso funktionieren !(?)</p>
</blockquote>
<p>Ein Cast weist den Compiler nur an &quot;wandle X in Y um&quot; - je nachdem welcher Cast verwendet wird mit gewissen Restriktionen. In dem besagten Fall würde der Cast vom Compiler durch den selben Konstruktoraufruf realisiert werden den wir hier angegeben haben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712145</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712145</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Mon, 18 May 2009 11:38:04 GMT</pubDate></item><item><title><![CDATA[Reply to Bestimmten String in std::vector ersetzen on Mon, 18 May 2009 11:53:02 GMT]]></title><description><![CDATA[<p>Ok, ich verstehe.</p>
<p>Danke ! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /><br />
Mir fehlts noch ziemlich an solchen Infos.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1712163</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1712163</guid><dc:creator><![CDATA[R3dNeXX]]></dc:creator><pubDate>Mon, 18 May 2009 11:53:02 GMT</pubDate></item></channel></rss>