<?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 encoding]]></title><description><![CDATA[<p>Welches encoding wird laut Standard für std::string verwendet?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/319381/std-string-encoding</link><generator>RSS for Node</generator><lastBuildDate>Sat, 25 Jul 2026 22:46:18 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/319381.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 16 Aug 2013 09:48:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 09:48:04 GMT]]></title><description><![CDATA[<p>Welches encoding wird laut Standard für std::string verwendet?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346299</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346299</guid><dc:creator><![CDATA[supersonic]]></dc:creator><pubDate>Fri, 16 Aug 2013 09:48:04 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 10:00:39 GMT]]></title><description><![CDATA[<p>keines...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346307</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346307</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Fri, 16 Aug 2013 10:00:39 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 10:06:26 GMT]]></title><description><![CDATA[<p><strong>std::string</strong> hält Charaktere als <strong>char</strong> Array, womit diesen jeweils 1 Byte zur Verfügung steht. Wie dieser nun verwendet wird ist im Standard nicht definiert, wobei man für Windows ANSI und für Unix UTF-8 annehmen könnte anhand der Ausgabe durch OS API Funktionen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346312</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346312</guid><dc:creator><![CDATA[Youka]]></dc:creator><pubDate>Fri, 16 Aug 2013 10:06:26 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 10:06:53 GMT]]></title><description><![CDATA[<p>std::string ist nichts anderes als ein vector&lt;char&gt;, der speziell auf Zeichenketten spezialisiert ist und ein paar Komfortfunktionen hat die keiner braucht (find_last_not_of()? wtf?).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346313</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346313</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Fri, 16 Aug 2013 10:06:53 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 10:47:27 GMT]]></title><description><![CDATA[<p>Nathan schrieb:</p>
<blockquote>
<p>std::string ist nichts anderes als ein vector&lt;char&gt;, der speziell auf Zeichenketten spezialisiert ist und ein paar Komfortfunktionen hat die keiner braucht (find_last_not_of()? wtf?).</p>
</blockquote>
<p>Nicht ganz, der C++-String hat eine Optimierung für kleine Längen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346330</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346330</guid><dc:creator><![CDATA[bjarne stroustrup55]]></dc:creator><pubDate>Fri, 16 Aug 2013 10:47:27 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 10:49:22 GMT]]></title><description><![CDATA[<p>bjarne stroustrup55 schrieb:</p>
<blockquote>
<p>Nathan schrieb:</p>
<blockquote>
<p>std::string ist nichts anderes als ein vector&lt;char&gt;, der speziell auf Zeichenketten spezialisiert ist und ein paar Komfortfunktionen hat die keiner braucht (find_last_not_of()? wtf?).</p>
</blockquote>
<p>Nicht ganz, der C++-String hat eine Optimierung für kleine Längen.</p>
</blockquote>
<p>Siehe hier: <a href="http://john-ahlgren.blogspot.de/2012/03/small-string-optimization-and-move.html" rel="nofollow">http://john-ahlgren.blogspot.de/2012/03/small-string-optimization-and-move.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346331</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346331</guid><dc:creator><![CDATA[bjarne stroustrup55]]></dc:creator><pubDate>Fri, 16 Aug 2013 10:49:22 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 11:17:48 GMT]]></title><description><![CDATA[<blockquote>
<p>find_last_not_of()? wtf?</p>
</blockquote>
<p>Also ich habe das bereits einige Male gebraucht. Ich sehe nicht ein wieso du das so pauschal runtermachen musst. PI war auch der Meinung, <code>std::string</code> habe zu viele Member - ...</p>
<blockquote>
<p>Welches encoding wird laut Standard für std::string verwendet?</p>
</blockquote>
<p>Das ist nicht die richtige Frage. std::string macht nämlich nichts Encoding-spezifisches. Daher wäre eine richtige Antwort: Es <em>unterstützt</em> alle.</p>
<p>Vielleicht meinst du auch das interne Encoding mit dem bspw. Zeichenkettenliterale encodet werden...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346336</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346336</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Fri, 16 Aug 2013 11:17:48 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 11:17:03 GMT]]></title><description><![CDATA[<p>PI?<br />
Ich persönlich habe das noch nie gebraucht. Und werde es seit den regulären Ausdrücken vermutlich noch weniger brauchen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346338</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346338</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Fri, 16 Aug 2013 11:17:03 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 11:17:18 GMT]]></title><description><![CDATA[<p>bjarne stroustrup55 schrieb:</p>
<blockquote>
<p>Nicht ganz, der C++-String hat eine Optimierung für kleine Längen.</p>
</blockquote>
<p>Nein. Er hat <em>möglicherweise</em> Optimierungen für Zeichenketten, welche <em>möglicherweise</em> auch eine Optimierung für kurze Längen sein <em>kann</em>.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346339</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346339</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 16 Aug 2013 11:17:18 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 11:19:24 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>bjarne stroustrup55 schrieb:</p>
<blockquote>
<p>Nicht ganz, der C++-String hat eine Optimierung für kleine Längen.</p>
</blockquote>
<p>Nein. Er hat <em>möglicherweise</em> Optimierungen für Zeichenketten, welche <em>möglicherweise</em> auch eine Optimierung für kurze Längen sein <em>kann</em>.</p>
</blockquote>
<p>Bzw. die Implementierung eines <code>std::string</code> hat die Optimierungen. Denn <strong>der</strong> C++-String aus dem Standard hat keine. Nur vielleicht eine Implementierung von GCC/VC++ und Konsorten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346340</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346340</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Fri, 16 Aug 2013 11:19:24 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 11:19:31 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Er hat <em>möglicherweise</em> Optimierungen für Zeichenketten, welche <em>möglicherweise</em> auch eine Optimierung für kurze Längen sein <em>kann</em>.</p>
</blockquote>
<p>Welche andere Optimierung wäre denn noch denkbar?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346341</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346341</guid><dc:creator><![CDATA[muh]]></dc:creator><pubDate>Fri, 16 Aug 2013 11:19:31 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 11:21:07 GMT]]></title><description><![CDATA[<p>Sone schrieb:</p>
<blockquote>
<p>PI war auch der Meinung, <code>std::string</code> habe zu viele Member</p>
</blockquote>
<p>Ja, und da ist er nicht ganz alleine. Das Interface von <code>std::string</code> ist eine Katastrophe.</p>
<p><a href="http://www.gotw.ca/gotw/084.htm" rel="nofollow">http://www.gotw.ca/gotw/084.htm</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346342</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346342</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Fri, 16 Aug 2013 11:21:07 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 11:52:25 GMT]]></title><description><![CDATA[<p>Nexus schrieb:</p>
<blockquote>
<p>Sone schrieb:</p>
<blockquote>
<p>PI war auch der Meinung, <code>std::string</code> habe zu viele Member</p>
</blockquote>
<p>Ja, und da ist er nicht ganz alleine. Das Interface von <code>std::string</code> ist eine Katastrophe.</p>
</blockquote>
<p>Dem habe ich nicht widersprochen. <code>find_first_not_of</code> muss aber für Strings in irgendeiner Weise spezialisiert werden, weil es möglich sein sollte es mit einem String-Literal o.ä. aufzurufen.</p>
<p>Das es an <code>std::string</code> gekoppelt ist ist natürlich doof. Eigentlich sollte das für jeden Container gehen, und eine Überladung für <code>char</code> / <code>char16_t</code> /... als Wertetyp ist auch nicht schwer. Nur finde ich es wiederum praktisch, eine Variante in <code>std::string</code> zu haben die auch Bequem für Strings aufzurufen ist.</p>
<p>Ein <code>find_last_not_of</code> wie dieses hier*</p>
<pre><code>template&lt;typename BidirectionalIterator,
         typename ForwardIterator,
         typename ValueT&gt;
BidirectionalIterator find_last_not_of( BidirectionalIterator first,
							         	BidirectionalIterator last,
								        ForwardIterator first2,
								        ForwardIterator last2 )
{
	auto iter = last;

	for(;;)
	{
		if( iter == first )
			break;

		if( std::find(first2, last2, *--iter) != last2 )
			return iter;
	}

	return last;
}
</code></pre>
<p>ist mit Strings umständlicher zu bedienen.</p>
<pre><code>std::string str(&quot;ABCDEFGHIJ&quot;);
char const ptr[] = &quot;AEIOU&quot;; 
auto iter = find_last_not_of( std::begin(str), std::end(str), std::begin(ptr), std::end(ptr) );
</code></pre>
<p>(anstatt</p>
<pre><code>std::string str(&quot;ABCDEFGHIJ&quot;);
auto pos = str.find_last_not_of(&quot;AEIOU&quot;);
</code></pre>
<p>)</p>
<p>Es stimmt jedoch, diese Bequemlichkeit kompensiert die Unflexibilität nicht.</p>
<p>~* Ich konnte nicht widerstehen. Ungetestet.~</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346358</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346358</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Fri, 16 Aug 2013 11:52:25 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 11:53:20 GMT]]></title><description><![CDATA[<p>Meine Güte, habe ich Sehstörungen? Ich dachte, knivil hätte den Post oben geschrieben...es war Nexus. habe ich irgendeine Leseschwäche?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346364</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346364</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Fri, 16 Aug 2013 11:53:20 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 11:58:34 GMT]]></title><description><![CDATA[<p>Also wenn std::string schon eigene Memberfunktionen hat, dann sollen die gefälligst auch optimiert sein (KMP und so). Stattdessen sind sie die unnötigsten Brute-Force-Implementierungen (siehe Sone), die eigentlich besser über reverse_iterator + find_first_not_of implementiert wären.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346366</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346366</guid><dc:creator><![CDATA[kmp]]></dc:creator><pubDate>Fri, 16 Aug 2013 11:58:34 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 12:21:17 GMT]]></title><description><![CDATA[<p>muh schrieb:</p>
<blockquote>
<p>SeppJ schrieb:</p>
<blockquote>
<p>Er hat <em>möglicherweise</em> Optimierungen für Zeichenketten, welche <em>möglicherweise</em> auch eine Optimierung für kurze Längen sein <em>kann</em>.</p>
</blockquote>
<p>Welche andere Optimierung wäre denn noch denkbar?</p>
</blockquote>
<p>Optimierung auf die Zeichenketten &quot;Hello World!&quot;, &quot;Foo&quot;, &quot;Bar&quot; und 252 weitere.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346384</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346384</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 16 Aug 2013 12:21:17 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 12:23:45 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Optimierung auf die Zeichenketten &quot;Hello World!&quot;, &quot;Foo&quot;, &quot;Bar&quot; und 252 weitere.</p>
</blockquote>
<p>Wie willst du das machen?</p>
<pre><code class="language-cpp">std::string s = &quot;Foo&quot;;
char *c = &amp;s[1];
*c = '!';
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2346387</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346387</guid><dc:creator><![CDATA[muh]]></dc:creator><pubDate>Fri, 16 Aug 2013 12:23:45 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 12:30:40 GMT]]></title><description><![CDATA[<p>Youka schrieb:</p>
<blockquote>
<p><strong>std::string</strong> hält Charaktere als <strong>char</strong> Array, womit diesen jeweils 1 Byte zur Verfügung steht. Wie dieser nun verwendet wird ist im Standard nicht definiert, wobei man für Windows ANSI und für Unix UTF-8 annehmen könnte anhand der Ausgabe durch OS API Funktionen.</p>
</blockquote>
<p>Und wie kann man dann ein File mit<br />
fstream (const string&amp; filename, ios_base::openmode mode = ios_base::in | ios_base::out);<br />
richtig öffnen?<br />
Muss ich meine strings Betriebsystem spezifisch konvertieren?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346391</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346391</guid><dc:creator><![CDATA[supersonic]]></dc:creator><pubDate>Fri, 16 Aug 2013 12:30:40 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 12:47:07 GMT]]></title><description><![CDATA[<p>muh schrieb:</p>
<blockquote>
<p>SeppJ schrieb:</p>
<blockquote>
<p>Optimierung auf die Zeichenketten &quot;Hello World!&quot;, &quot;Foo&quot;, &quot;Bar&quot; und 252 weitere.</p>
</blockquote>
<p>Wie willst du das machen?</p>
<pre><code class="language-cpp">std::string s = &quot;Foo&quot;;
char *c = &amp;s[1];
*c = '!';
</code></pre>
</blockquote>
<p>Die Optimierung merkt natürlich, sobald eine non-const Memberfunktion aufgerufen wird und schaltet dann in den normalen Modus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346399</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346399</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 16 Aug 2013 12:47:07 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 12:52:27 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Die Optimierung merkt natürlich, sobald eine non-const Memberfunktion aufgerufen wird und schaltet dann in den normalen Modus.</p>
</blockquote>
<p>Ohne bad_alloc?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346403</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346403</guid><dc:creator><![CDATA[muh]]></dc:creator><pubDate>Fri, 16 Aug 2013 12:52:27 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 12:53:51 GMT]]></title><description><![CDATA[<p>kmp schrieb:</p>
<blockquote>
<p>die eigentlich besser über reverse_iterator + find_first_not_of implementiert wären.</p>
</blockquote>
<p>Weil du dann Sechs Zeilen Code weniger schreiben musst? Weil es flexibler ist? Aber ich sehe da nur den Umstand, das literarische Programmieren aufzugeben. Der Funktionsname sollte doch schon möglichst für sich sprechen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346405</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346405</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Fri, 16 Aug 2013 12:53:51 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 13:11:08 GMT]]></title><description><![CDATA[<p>muh schrieb:</p>
<blockquote>
<p>SeppJ schrieb:</p>
<blockquote>
<p>Die Optimierung merkt natürlich, sobald eine non-const Memberfunktion aufgerufen wird und schaltet dann in den normalen Modus.</p>
</blockquote>
<p>Ohne bad_alloc?</p>
</blockquote>
<p>Klar doch! Es ist keine Platzoptimierung. Die Zeichenkette wird ganz normal gespeichert. Und noch ein weiteres Byte, das anzeigt, ob es sich um eine bekannte Sequenz handelt. Bloß die ganzen Suchmemberfunktionen sind optimiert und benutzen einen Lookup-Table für die optimierten Fälle.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346419</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346419</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 16 Aug 2013 13:11:08 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 14:00:38 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>muh schrieb:</p>
<blockquote>
<p>SeppJ schrieb:</p>
<blockquote>
<p>Die Optimierung merkt natürlich, sobald eine non-const Memberfunktion aufgerufen wird und schaltet dann in den normalen Modus.</p>
</blockquote>
<p>Ohne bad_alloc?</p>
</blockquote>
<p>Klar doch! Es ist keine Platzoptimierung. Die Zeichenkette wird ganz normal gespeichert. Und noch ein weiteres Byte, das anzeigt, ob es sich um eine bekannte Sequenz handelt. Bloß die ganzen Suchmemberfunktionen sind optimiert und benutzen einen Lookup-Table für die optimierten Fälle.</p>
</blockquote>
<pre><code class="language-cpp">std::string s = &quot;Foo&quot;;
std::string t = &quot;Foo&quot;;
char *c = &amp;s[1]; // s welchselt in normalen Modus
std::cout &lt;&lt; (s == t) &lt;&lt; '\n'; // s checkt sich selber erneut nach jedem der 255 Magic-Strings!?
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2346440</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346440</guid><dc:creator><![CDATA[muh]]></dc:creator><pubDate>Fri, 16 Aug 2013 14:00:38 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 14:26:32 GMT]]></title><description><![CDATA[<p>muh schrieb:</p>
<blockquote>
<p>[code=&quot;cpp&quot;]<br />
std::cout &lt;&lt; (s == t) &lt;&lt; '\n'; // s checkt sich selber erneut nach jedem der 255 Magic-Strings!?[/cpp]</p>
</blockquote>
<p>Nein, s vergleicht sich einfach mit t. Jeder der Strings kennt zu jeder Zeit seinen genauen Wert.</p>
<p>Selbst wenn dies nicht so <em>wäre</em>, so ist die Komplexität von == nicht vorgegeben. Das wäre dann eben ein Kompromiss bei der Optimierung, dass == langsamer wird, anderes dafür schneller.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346447</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346447</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 16 Aug 2013 14:26:32 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 18:48:04 GMT]]></title><description><![CDATA[<p>Sone schrieb:</p>
<blockquote>
<p>Nexus schrieb:</p>
<blockquote>
<p>Sone schrieb:</p>
<blockquote>
<p>PI war auch der Meinung, <code>std::string</code> habe zu viele Member</p>
</blockquote>
<p>Ja, und da ist er nicht ganz alleine. Das Interface von <code>std::string</code> ist eine Katastrophe.</p>
</blockquote>
<p>Dem habe ich nicht widersprochen. <code>find_first_not_of</code> muss aber für Strings in irgendeiner Weise spezialisiert werden, weil es möglich sein sollte es mit einem String-Literal o.ä. aufzurufen.</p>
<p>Das es an <code>std::string</code> gekoppelt ist ist natürlich doof. Eigentlich sollte das für jeden Container gehen, und eine Überladung für <code>char</code> / <code>char16_t</code> /... als Wertetyp ist auch nicht schwer. Nur finde ich es wiederum praktisch, eine Variante in <code>std::string</code> zu haben die auch Bequem für Strings aufzurufen ist.</p>
<p>Ein <code>find_last_not_of</code> wie dieses hier*</p>
<pre><code>template&lt;typename BidirectionalIterator,
         typename ForwardIterator,
         typename ValueT&gt;
BidirectionalIterator find_last_not_of( BidirectionalIterator first,
							         	BidirectionalIterator last,
								        ForwardIterator first2,
								        ForwardIterator last2 )
{
	auto iter = last;

	for(;;)
	{
		if( iter == first )
			break;
			
		if( std::find(first2, last2, *--iter) != last2 )
			return iter;
	}
	
	return last;
}
</code></pre>
<p>ist mit Strings umständlicher zu bedienen.</p>
<pre><code>std::string str(&quot;ABCDEFGHIJ&quot;);
char const ptr[] = &quot;AEIOU&quot;; 
auto iter = find_last_not_of( std::begin(str), std::end(str), std::begin(ptr), std::end(ptr) );
</code></pre>
<p>(anstatt</p>
<pre><code>std::string str(&quot;ABCDEFGHIJ&quot;);
auto pos = str.find_last_not_of(&quot;AEIOU&quot;);
</code></pre>
<p>)</p>
<p>Es stimmt jedoch, diese Bequemlichkeit kompensiert die Unflexibilität nicht.</p>
<p>~* Ich konnte nicht widerstehen. Ungetestet.~</p>
</blockquote>
<p>Man kann natürlich einfach Überladungen anbieten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346506</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346506</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Fri, 16 Aug 2013 18:48:04 GMT</pubDate></item><item><title><![CDATA[Reply to std::string encoding on Fri, 16 Aug 2013 19:55:47 GMT]]></title><description><![CDATA[<p>Das meinte ich ja, Überladen. (Mit in &quot;irgendeiner Weise spezialisiert&quot;, wobei der Begriff Spezialisierung in diesem Kontext natürlich völlig falsch gebraucht wurde)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346517</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346517</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Fri, 16 Aug 2013 19:55:47 GMT</pubDate></item></channel></rss>