<?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[MAP auf Pointer auf Funktion und Pointer auf Variable]]></title><description><![CDATA[<p>Hallo,</p>
<p>vielleicht habt ihr eine Idee:</p>
<p>Ich habe mehrere Funtkionen, zu jeder Funktion eine Variable und eine Bezeichnung der Funktion.</p>
<p>Jeder Funktion wird ein vector&lt;T&gt; übergeben. Es sind Templatefunktionen.<br />
Es gibt eine Funktion, die die Templatefunktionen aufruft Zeitdauer misst und die Zeit in einer übergebenen Variable speichert.</p>
<p>Wie stelle ich das nun am besten an?<br />
Ich hatte an map&lt;void <em>,double <em>&gt; und map&lt;string,map&gt; oder so gedacht. das zweite mach natürlich keinen sinn. Will ja nicht für jede Funktion eine map erzeugen.<br />
Als Schema: string, void (</em>)(&lt;vector&lt;T&gt;), double</em><br />
Erstes soll die Bezeichnung der Funktion sein, das zweite ein Pointer auf die Funktion mit dem übergebenen Vektor vom Typ T und das letzte soll die zugehörige Variable sein, in der die Zeit gespeichert werden soll.<br />
Hatte an Structs gedacht, aber die Funktionieren nicht mit Templateklassen.</p>
<p>Ich hoffe ich konnte mich verständlich ausdrücken und ihr habt eine Idee für mich.</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/316563/map-auf-pointer-auf-funktion-und-pointer-auf-variable</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Jul 2026 22:58:10 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/316563.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 08 May 2013 10:48:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to MAP auf Pointer auf Funktion und Pointer auf Variable on Wed, 08 May 2013 10:48:47 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>vielleicht habt ihr eine Idee:</p>
<p>Ich habe mehrere Funtkionen, zu jeder Funktion eine Variable und eine Bezeichnung der Funktion.</p>
<p>Jeder Funktion wird ein vector&lt;T&gt; übergeben. Es sind Templatefunktionen.<br />
Es gibt eine Funktion, die die Templatefunktionen aufruft Zeitdauer misst und die Zeit in einer übergebenen Variable speichert.</p>
<p>Wie stelle ich das nun am besten an?<br />
Ich hatte an map&lt;void <em>,double <em>&gt; und map&lt;string,map&gt; oder so gedacht. das zweite mach natürlich keinen sinn. Will ja nicht für jede Funktion eine map erzeugen.<br />
Als Schema: string, void (</em>)(&lt;vector&lt;T&gt;), double</em><br />
Erstes soll die Bezeichnung der Funktion sein, das zweite ein Pointer auf die Funktion mit dem übergebenen Vektor vom Typ T und das letzte soll die zugehörige Variable sein, in der die Zeit gespeichert werden soll.<br />
Hatte an Structs gedacht, aber die Funktionieren nicht mit Templateklassen.</p>
<p>Ich hoffe ich konnte mich verständlich ausdrücken und ihr habt eine Idee für mich.</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2321940</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2321940</guid><dc:creator><![CDATA[JohKa]]></dc:creator><pubDate>Wed, 08 May 2013 10:48:47 GMT</pubDate></item><item><title><![CDATA[Reply to MAP auf Pointer auf Funktion und Pointer auf Variable on Wed, 08 May 2013 11:14:45 GMT]]></title><description><![CDATA[<p>JohKa schrieb:</p>
<blockquote>
<p>Hatte an Structs gedacht, aber die Funktionieren nicht mit Templateklassen.</p>
</blockquote>
<p>What. Warum?</p>
<pre><code class="language-cpp">template&lt;typename Type&gt;
struct Function{
	void(*function)(std::vector&lt;Type&gt;);
	double time_elapsed;
};

std::map&lt;std::string, Function&lt;T&gt;&gt; my_functions_map;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2321944</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2321944</guid><dc:creator><![CDATA[F13]]></dc:creator><pubDate>Wed, 08 May 2013 11:14:45 GMT</pubDate></item><item><title><![CDATA[Reply to MAP auf Pointer auf Funktion und Pointer auf Variable on Wed, 08 May 2013 12:48:55 GMT]]></title><description><![CDATA[<p>Danke für die schnelle Antwort:</p>
<p>Bei deinem Vorschlag erhalte ich:<br />
error C2133: my_function_map: unbekannte Größe<br />
error C2998: std::map&lt;std::string, Function&lt;T&gt;&gt; my_functions_map; Kann keine Vorlagedefinition sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2321974</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2321974</guid><dc:creator><![CDATA[JohKa]]></dc:creator><pubDate>Wed, 08 May 2013 12:48:55 GMT</pubDate></item><item><title><![CDATA[Reply to MAP auf Pointer auf Funktion und Pointer auf Variable on Wed, 08 May 2013 13:03:22 GMT]]></title><description><![CDATA[<p>Ich glaube Du hast da noch ein paar Lücken was Dein Wissen von Templates angeht.<br />
<code>T</code> musst Du natürlich durch den entsprechenden Typen den Du benutzen willst ersetzen.</p>
<p>Folgender Code</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;map&gt;

template&lt;typename Type&gt;
struct Function{
	void(*function)(std::vector&lt;Type&gt;);
	double time_elapsed;
};

int main(){
	std::map&lt;std::string, Function&lt;int&gt;&gt; my_function_map;
	return 0;
}
</code></pre>
<p>kompiliert einwandfrei.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2321978</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2321978</guid><dc:creator><![CDATA[F13]]></dc:creator><pubDate>Wed, 08 May 2013 13:03:22 GMT</pubDate></item><item><title><![CDATA[Reply to MAP auf Pointer auf Funktion und Pointer auf Variable on Wed, 08 May 2013 13:05:31 GMT]]></title><description><![CDATA[<p>Und zeige mal ein Stück Code wo es kracht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2321979</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2321979</guid><dc:creator><![CDATA[F13]]></dc:creator><pubDate>Wed, 08 May 2013 13:05:31 GMT</pubDate></item><item><title><![CDATA[Reply to MAP auf Pointer auf Funktion und Pointer auf Variable on Wed, 08 May 2013 13:44:23 GMT]]></title><description><![CDATA[<p>Danke nochmal!</p>
<p>Hatte einen Gedankenfehler. Nun klappts.<br />
Aber wie fülle ich die jetzt mit inhalten?</p>
<p>my_functions = {STRING,{funktion,variable}}?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2321984</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2321984</guid><dc:creator><![CDATA[JohKa]]></dc:creator><pubDate>Wed, 08 May 2013 13:44:23 GMT</pubDate></item><item><title><![CDATA[Reply to MAP auf Pointer auf Funktion und Pointer auf Variable on Wed, 08 May 2013 14:25:09 GMT]]></title><description><![CDATA[<pre><code>my_function_map[&quot;Zeichenkette&quot;] = Function-Instanz;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2321995</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2321995</guid><dc:creator><![CDATA[out]]></dc:creator><pubDate>Wed, 08 May 2013 14:25:09 GMT</pubDate></item><item><title><![CDATA[Reply to MAP auf Pointer auf Funktion und Pointer auf Variable on Wed, 08 May 2013 17:34:26 GMT]]></title><description><![CDATA[<p>JohKa schrieb:</p>
<blockquote>
<p>my_functions = {STRING,{funktion,variable}}</p>
</blockquote>
<p>Wenn Dein Compiler <code>std::initializer_list&lt;&gt;</code> versteht, dann ja.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2322021</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2322021</guid><dc:creator><![CDATA[F13]]></dc:creator><pubDate>Wed, 08 May 2013 17:34:26 GMT</pubDate></item><item><title><![CDATA[Reply to MAP auf Pointer auf Funktion und Pointer auf Variable on Fri, 10 May 2013 08:06:25 GMT]]></title><description><![CDATA[<p>Guten Morgen,</p>
<p>ich habe den struct nun so gelöst:</p>
<pre><code>template &lt;class T&gt;
struct Function {	
	void (*pFunc)(vector&lt;T&gt;);
	string exp;
	double *time_elapsed;
};
</code></pre>
<p>Also keine Map mehr genommen sondern alle Informtionen im Struct gespeichert.<br />
Initialisiert habe den dann wie folgt:</p>
<pre><code>Function&lt;int&gt; functions[] = {
		{ func1 , &quot;Funktion 1&quot; , &amp;varFunc1 },
		{ func2 , &quot;Funktion 2&quot; , &amp;varFunc2 },
	};
</code></pre>
<p>Jedoch erhalte ich den Fehler: &quot;Keine Instanz von Funktionsvorlage func1 stimmt mit den erforderlichen Typen überein.</p>
<p>Implementierung von func1,2... ist:</p>
<pre><code>template &lt;class T&gt;
void func1 (vector&lt;T&gt; &amp;data) {
...
}
</code></pre>
<p>Hat jemand eine Idee für mich?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2322374</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2322374</guid><dc:creator><![CDATA[JohKa]]></dc:creator><pubDate>Fri, 10 May 2013 08:06:25 GMT</pubDate></item><item><title><![CDATA[Reply to MAP auf Pointer auf Funktion und Pointer auf Variable on Fri, 10 May 2013 09:15:07 GMT]]></title><description><![CDATA[<p>Du deklarierst in deinem struct, dass deine Funktion einen vector per Value nimmt:</p>
<pre><code>void (*pFunc)(vector&lt;T&gt;);
</code></pre>
<p>, aber deine Funktion nimmt einen vector per Referenz:</p>
<pre><code>void func1 (vector&lt;T&gt; &amp;data) {
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2322382</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2322382</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Fri, 10 May 2013 09:15:07 GMT</pubDate></item><item><title><![CDATA[Reply to MAP auf Pointer auf Funktion und Pointer auf Variable on Fri, 10 May 2013 09:26:28 GMT]]></title><description><![CDATA[<p>Ok, dass das so einfach ist, hätte ich nicht gedacht!!! Vielen Dank!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2322384</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2322384</guid><dc:creator><![CDATA[JohKa]]></dc:creator><pubDate>Fri, 10 May 2013 09:26:28 GMT</pubDate></item></channel></rss>