<?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[template soll element in Struktur adressieren]]></title><description><![CDATA[<p>Hallo<br />
ich habe folgendes Problem:<br />
Ich will Funktion ModelCodesEq als ein template umformulieren.</p>
<p>Der vector&lt;EtsTypPtr&gt; ist ein Vector von shared_ptr&lt;EtsTyp&gt;.<br />
Das Element typ_modell_code soll hierbei als Templateparameter dienen.</p>
<pre><code class="language-cpp">struct EtsTyp
{
	explicit EtsTyp(const CRecord &amp;Rec) ;

	int typ_schwackecode ;
	std::string typ_vehicle_type ;
	int  typ_make_code ;
	int typ_modell_code ;
	std::string typ_name ;
	std::string typ_edition_line ;
	int typ_fueltype ;
	int typ_bodytype ;
	int typ_transmission ;
	int typ_geartype ;
	int typ_gears ;
	int typ_doors ;
	int typ_ccm ;
	int typ_kw ;
	int typ_cylinder ;
	int typ_gvw ;
	int typ_wheelbase ;
	int typ_net_weight ;
	int typ_payload ;
	int typ_seats ;
	CMonthYear typ_prodbeg ;
	CMonthYear typ_prodend ;
	bool InProdTimes(const CMonthYear &amp;RegMonthYear) const ;
	bool NotInProdTimes(const CMonthYear &amp;RegMonthYear) const ;
} ;
</code></pre>
<pre><code class="language-cpp">bool ModelCodesEq(const vector&lt;EtsTypPtr&gt; &amp;FoundedCodes) const
{
	return find_if(FoundedCodes.begin(),FoundedCodes.end(),
		     bind(std::not_equal_to&lt;int(),bind(&amp;EtsTyp::typ_modell_code,_1),(*FoundedCodes.begin())-&gt;typ_modell_code ))==FoundedCodes.end() ;
}
</code></pre>
<p>Es soll möglich sein die einzelnen Elemente der Struktur als template Parameter<br />
anzugeben,statt typ_modell_code nun typ_bodytype.<br />
Ich hab keinen Schimmmer wie ich das Ganze formulieren muss.</p>
<p>Danke für eure Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/267534/template-soll-element-in-struktur-adressieren</link><generator>RSS for Node</generator><lastBuildDate>Wed, 02 Sep 2026 10:49:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/267534.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 26 May 2010 09:13:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to template soll element in Struktur adressieren on Wed, 26 May 2010 09:13:33 GMT]]></title><description><![CDATA[<p>Hallo<br />
ich habe folgendes Problem:<br />
Ich will Funktion ModelCodesEq als ein template umformulieren.</p>
<p>Der vector&lt;EtsTypPtr&gt; ist ein Vector von shared_ptr&lt;EtsTyp&gt;.<br />
Das Element typ_modell_code soll hierbei als Templateparameter dienen.</p>
<pre><code class="language-cpp">struct EtsTyp
{
	explicit EtsTyp(const CRecord &amp;Rec) ;

	int typ_schwackecode ;
	std::string typ_vehicle_type ;
	int  typ_make_code ;
	int typ_modell_code ;
	std::string typ_name ;
	std::string typ_edition_line ;
	int typ_fueltype ;
	int typ_bodytype ;
	int typ_transmission ;
	int typ_geartype ;
	int typ_gears ;
	int typ_doors ;
	int typ_ccm ;
	int typ_kw ;
	int typ_cylinder ;
	int typ_gvw ;
	int typ_wheelbase ;
	int typ_net_weight ;
	int typ_payload ;
	int typ_seats ;
	CMonthYear typ_prodbeg ;
	CMonthYear typ_prodend ;
	bool InProdTimes(const CMonthYear &amp;RegMonthYear) const ;
	bool NotInProdTimes(const CMonthYear &amp;RegMonthYear) const ;
} ;
</code></pre>
<pre><code class="language-cpp">bool ModelCodesEq(const vector&lt;EtsTypPtr&gt; &amp;FoundedCodes) const
{
	return find_if(FoundedCodes.begin(),FoundedCodes.end(),
		     bind(std::not_equal_to&lt;int(),bind(&amp;EtsTyp::typ_modell_code,_1),(*FoundedCodes.begin())-&gt;typ_modell_code ))==FoundedCodes.end() ;
}
</code></pre>
<p>Es soll möglich sein die einzelnen Elemente der Struktur als template Parameter<br />
anzugeben,statt typ_modell_code nun typ_bodytype.<br />
Ich hab keinen Schimmmer wie ich das Ganze formulieren muss.</p>
<p>Danke für eure Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1902624</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1902624</guid><dc:creator><![CDATA[case]]></dc:creator><pubDate>Wed, 26 May 2010 09:13:33 GMT</pubDate></item><item><title><![CDATA[Reply to template soll element in Struktur adressieren on Wed, 26 May 2010 19:50:08 GMT]]></title><description><![CDATA[<p>Wie soll ein <code>int</code> als ein Templateparameter dienen?</p>
<p>Beschreib mal genau, <strong>was</strong> du erreichen willst und nicht <strong>wie</strong>.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1902923</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1902923</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Wed, 26 May 2010 19:50:08 GMT</pubDate></item><item><title><![CDATA[Reply to template soll element in Struktur adressieren on Wed, 26 May 2010 20:47:39 GMT]]></title><description><![CDATA[<p>Meinst du sowas?</p>
<pre><code class="language-cpp">template&lt;int EtsTyp::* code&gt;
bool ModelCodesEq(const vector&lt;EtsTypPtr&gt; &amp;FoundedCodes) const
{
    return find_if(FoundedCodes.begin(),FoundedCodes.end(),
             bind(std::not_equal_to&lt;int(),bind(code,_1),(*FoundedCodes.begin())-&gt;*code ))==FoundedCodes.end() ;
}

//Aufruf:
if(ModelCodesEq&lt;&amp;EtsTyp::typ_modell_code&gt;(irgendein_vector)) ...;
</code></pre>
<p>Keine Ahnung, ob das so funktioniert, aber falls, könntest du diesen <code>int EtsTyp::* code</code> auch als normalen Parameter übergeben, ich sehe jetzt nicht unbedingt, warum das ein Templateparameter sein muss, das macht das ganze imho nur unleserlich.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1902941</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1902941</guid><dc:creator><![CDATA[ipsec]]></dc:creator><pubDate>Wed, 26 May 2010 20:47:39 GMT</pubDate></item><item><title><![CDATA[Reply to template soll element in Struktur adressieren on Thu, 27 May 2010 08:27:16 GMT]]></title><description><![CDATA[<p>ipsec schrieb:</p>
<blockquote>
<p>ich sehe jetzt nicht unbedingt, warum das ein Templateparameter sein muss, das macht das ganze imho nur unleserlich.</p>
</blockquote>
<p>Evtl. sols ein Template werden weil es nicht immer um einen int geht. Das wäre dann in etwas sowas:</p>
<pre><code class="language-cpp">template&lt;class T&gt;
bool ModelCodesEq(const vector&lt;EtsTypPtr&gt; &amp;FoundedCodes, T EtsTyp::* memPtr) const
{
    return find_if(FoundedCodes.begin(),
                   FoundedCodes.end(),
                   bind(std::not_equal_to&lt;T&gt;(),bind(memPtr,_1), (*FoundedCodes.begin())-&gt;*memPtr )
                  ) == FoundedCodes.end() ;
}

//Aufruf:
if(ModelCodesEq(irgendein_vector, &amp;EtsTyp::typ_modell_code)) ...;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1903022</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1903022</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Thu, 27 May 2010 08:27:16 GMT</pubDate></item><item><title><![CDATA[Reply to template soll element in Struktur adressieren on Thu, 27 May 2010 08:19:24 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>pumuckl hat mein Problem gelöst.<br />
Genau das hab ich gesucht.<br />
Ich habe das Ganze zwar schon mit einem Predicate gelöst, aber pumuckls Lösung<br />
sieht um einiges besser aus.</p>
<p>Danke an euch alle.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1903064</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1903064</guid><dc:creator><![CDATA[case]]></dc:creator><pubDate>Thu, 27 May 2010 08:19:24 GMT</pubDate></item></channel></rss>