<?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[vector&amp;lt;string&amp;gt; &amp;quot;alle nicht-double elemente entfernen&amp;quot;]]></title><description><![CDATA[<p>hallo,</p>
<pre><code class="language-cpp">vector&lt;string&gt;::iterator it;
	it = remove_if(eingang.begin(),eingang.end(),bind2nd(not_equal_to&lt;double&gt;(), 0));
</code></pre>
<p>ich möchte aus meinem vector&lt;string&gt; alle elemente entfernen die nicht_numerisch sind, sprich int oder double.</p>
<p>geht das nicht mit &quot;not_equal_to&quot; ?</p>
<p>greez + thx</p>
<p>grizzel</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/152646/vector-lt-string-gt-quot-alle-nicht-double-elemente-entfernen-quot</link><generator>RSS for Node</generator><lastBuildDate>Sun, 06 Sep 2026 23:41:04 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/152646.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 08 Jul 2006 09:17:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to vector&amp;lt;string&amp;gt; &amp;quot;alle nicht-double elemente entfernen&amp;quot; on Sat, 08 Jul 2006 09:17:31 GMT]]></title><description><![CDATA[<p>hallo,</p>
<pre><code class="language-cpp">vector&lt;string&gt;::iterator it;
	it = remove_if(eingang.begin(),eingang.end(),bind2nd(not_equal_to&lt;double&gt;(), 0));
</code></pre>
<p>ich möchte aus meinem vector&lt;string&gt; alle elemente entfernen die nicht_numerisch sind, sprich int oder double.</p>
<p>geht das nicht mit &quot;not_equal_to&quot; ?</p>
<p>greez + thx</p>
<p>grizzel</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1093728</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1093728</guid><dc:creator><![CDATA[grizzzel]]></dc:creator><pubDate>Sat, 08 Jul 2006 09:17:31 GMT</pubDate></item><item><title><![CDATA[Reply to vector&amp;lt;string&amp;gt; &amp;quot;alle nicht-double elemente entfernen&amp;quot; on Sat, 08 Jul 2006 11:12:25 GMT]]></title><description><![CDATA[<p>grizzzel schrieb:</p>
<blockquote>
<p>geht das nicht mit &quot;not_equal_to&quot; ?</p>
</blockquote>
<p>not_equal_to&lt;T&gt; vergleicht zwei *Werte* vom Typ T. Es konvertiert nicht einen Wert vom Typ Y in den Typ T und vergleicht dann.</p>
<p>Du brauchst mehr sowas:</p>
<pre><code class="language-cpp">struct IsNum : std::unary_function&lt;bool, std::string&gt; {
	bool operator()(const std::string&amp; s) const {
		char* e;
		strtod(s.c_str(), &amp;e);
		return e == s.c_str() + s.length();
	}
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1093811</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1093811</guid><dc:creator><![CDATA[HumeSikkins]]></dc:creator><pubDate>Sat, 08 Jul 2006 11:12:25 GMT</pubDate></item><item><title><![CDATA[Reply to vector&amp;lt;string&amp;gt; &amp;quot;alle nicht-double elemente entfernen&amp;quot; on Sat, 08 Jul 2006 11:17:35 GMT]]></title><description><![CDATA[<p>geht das nicht mit &quot;remove_if&quot; ?<br />
ich dachte so:</p>
<p>remove_if(beginn,end,&lt;wenn nicht numerisch&gt;)</p>
<p>...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1093823</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1093823</guid><dc:creator><![CDATA[grizzzel]]></dc:creator><pubDate>Sat, 08 Jul 2006 11:17:35 GMT</pubDate></item><item><title><![CDATA[Reply to vector&amp;lt;string&amp;gt; &amp;quot;alle nicht-double elemente entfernen&amp;quot; on Sat, 08 Jul 2006 11:33:41 GMT]]></title><description><![CDATA[<p>grizzzel schrieb:</p>
<blockquote>
<p>geht das nicht mit &quot;remove_if&quot; ?<br />
ich dachte so:</p>
<p>remove_if(beginn,end,&lt;wenn nicht numerisch&gt;)</p>
<p>...</p>
</blockquote>
<p>remove_if ist nur der Algorithmus. Entscheidend ist hier das Prädikat.</p>
<pre><code class="language-cpp">// Achtung: In der ersten Variante hatte ich Argument- und Return-Type vertauscht.
struct IsNum : std::unary_function&lt;std::string, bool&gt; {
	bool operator()(const std::string&amp; s) const {
		char* e;
		strtod(s.c_str(), &amp;e);
		return e == s.c_str() + s.length();
	}
};

int main() {
	std::vector&lt;string&gt; v;
	v.push_back(&quot;Hallo&quot;);
	v.push_back(&quot;123&quot;);
	v.push_back(&quot;17.86&quot;);
	v.push_back(&quot;Welt&quot;);
	v.erase(std::remove_if(v.begin(), v.end(), std::not1(IsNum())), v.end());
	std::copy(v.begin(), v.end(), std::ostream_iterator&lt;std::string&gt;(std::cout, &quot;\n&quot;));

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1093837</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1093837</guid><dc:creator><![CDATA[HumeSikkins]]></dc:creator><pubDate>Sat, 08 Jul 2006 11:33:41 GMT</pubDate></item></channel></rss>