<?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[Dereferenzierung von map-Iterator kompiliert nicht]]></title><description><![CDATA[<p>Hi,</p>
<p>ich habe lange versucht das zu reproduzieren, aber ich schaffe es einfach nicht, jedenfalls nicht mit einer lokalen Klasse. Vielleicht hat jemand Hinweise für mich.</p>
<p>Also der nicht-kompilierende Code ist:</p>
<pre><code class="language-cpp">auto it = HandStrengthNames::names.begin();
	*it; // Fehler hier?! Fehlermeldung siehe ganz unten im Post
</code></pre>
<p>HandStrengthNames ist so definiert:</p>
<pre><code class="language-cpp">struct HandStrengthNames
{
	struct GreaterCountOfBits
	{
		bool operator()(const HandStrengthKey&amp; lhs, const HandStrengthKey&amp; rhs) const;
	};

	typedef std::map&lt;HandStrengthKey, std::string, GreaterCountOfBits&gt; HandStrengthNamesMapping;
	typedef HandStrengthNamesMapping::value_type ConstMappedHandStrength;

	static HandStrengthNamesMapping initialize();

	static HandStrengthNamesMapping names;
};
</code></pre>
<p>In der cpp-Datei steht dann:</p>
<pre><code class="language-cpp">HandStrengthNames::HandStrengthNamesMapping HandStrengthNames::names = HandStrengthNames::initialize();
</code></pre>
<p>Okay und HandStrengthKey sieht dann noch so aus:</p>
<pre><code class="language-cpp">struct DLL_SPECIFIER /* dllim/export */ HandStrengthKey
{
	HandStrengthDetailType	handStrengthDetail;
	HandStrengthDetailType	exclusiveHandStrengths;
	std::string				customLabel;

	HandStrengthKey(const HandStrengthDetailType&amp; handStrengthDetail, const HandStrengthDetailType&amp; exclusiveHandStrengths)
		: handStrengthDetail(handStrengthDetail), exclusiveHandStrengths(exclusiveHandStrengths) {}

	HandStrengthKey(const HandStrengthDetailType&amp; handStrengthDetail, const HandStrengthDetailType&amp; exclusiveHandStrengths,
		const std::string&amp; customLabel)
		: handStrengthDetail(handStrengthDetail), exclusiveHandStrengths(exclusiveHandStrengths),
	customLabel(customLabel) {}

	bool operator==(const HandStrengthKey&amp; rhs) const;
	bool operator!=(const HandStrengthKey&amp; rhs) const;
	HandStrengthKey&amp; operator|=(const HandStrengthKey&amp; rhs);
	HandStrengthKey&amp; operator&amp;=(const HandStrengthKey&amp; rhs);
	HandStrengthKey operator~() const;
	bool operator&lt;(const HandStrengthKey&amp; rhs) const;
};
</code></pre>
<p>wobei HandStrengthDetailType einfach ein uint64 ist.</p>
<p>Die Fehlermeldung ist mir absolut unbegreiflich und ich schaffe es auch nicht sie zu umgehen:</p>
<blockquote>
<p>1&gt; HandStrengthSelectionDialog.cpp<br />
1&gt;c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(260): error C2678: Binärer Operator '=': Es konnte kein Operator gefunden werden, der einen linksseitigen Operanden vom Typ 'const HandStrengthKey' akzeptiert (oder keine geeignete Konvertierung möglich)<br />
1&gt; c:\users\michael\documents\visual studio 2010\projects\ui\elypsonevaluatorbase\handstrengthkey.h(28): kann 'HandStrengthKey &amp;HandStrengthKey::operator =(const HandStrengthKey &amp;)' sein<br />
1&gt; bei Anpassung der Argumentliste '(const HandStrengthKey, const HandStrengthKey)'<br />
1&gt; c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(259): Bei der Kompilierung der Klassen-template der std::pair&lt;_Ty1,_Ty2&gt; &amp;std::pair&lt;_Ty1,_Ty2&gt;::operator =(std::pair&lt;_Ty1,_Ty2&gt; &amp;&amp;)-Memberfunktion<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Ty1=const HandStrengthKey,<br />
1&gt; _Ty2=std::string<br />
1&gt; ]<br />
1&gt; c:\users\michael\documents\visual studio 2010\projects\ui\...\handstrengthselectiondialog.cpp(113): Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template &quot;std::pair&lt;_Ty1,_Ty2&gt;&quot;.<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Ty1=const HandStrengthKey,<br />
1&gt; _Ty2=std::string<br />
1&gt; ] &lt;-- das ist der Code mit *it</p>
</blockquote>
<p>Die markierte Zeile im untersten Teil der Fehlermeldung ist eben die mit <code>*it</code> . D.h. er versucht irgendwo (?) eine Zuweisung zu machen.</p>
<p>Was ich eigentlich tun will ist eine simple Iteration durch alle map-Elemente. Aber ständig erhalte ich diese dämlichen Fehler, dass die Map ein pair nutzt, dessen first const ist, weswegen die Zuweisung in dieser utility-Funktion nicht klappt.</p>
<p>Irgendwelche Ideen?</p>
<p>Danke im Voraus und beste Grüße!<br />
Eisflamme</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/317157/dereferenzierung-von-map-iterator-kompiliert-nicht</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Jul 2026 11:26:19 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/317157.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 29 May 2013 14:16:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dereferenzierung von map-Iterator kompiliert nicht on Wed, 29 May 2013 14:24:53 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich habe lange versucht das zu reproduzieren, aber ich schaffe es einfach nicht, jedenfalls nicht mit einer lokalen Klasse. Vielleicht hat jemand Hinweise für mich.</p>
<p>Also der nicht-kompilierende Code ist:</p>
<pre><code class="language-cpp">auto it = HandStrengthNames::names.begin();
	*it; // Fehler hier?! Fehlermeldung siehe ganz unten im Post
</code></pre>
<p>HandStrengthNames ist so definiert:</p>
<pre><code class="language-cpp">struct HandStrengthNames
{
	struct GreaterCountOfBits
	{
		bool operator()(const HandStrengthKey&amp; lhs, const HandStrengthKey&amp; rhs) const;
	};

	typedef std::map&lt;HandStrengthKey, std::string, GreaterCountOfBits&gt; HandStrengthNamesMapping;
	typedef HandStrengthNamesMapping::value_type ConstMappedHandStrength;

	static HandStrengthNamesMapping initialize();

	static HandStrengthNamesMapping names;
};
</code></pre>
<p>In der cpp-Datei steht dann:</p>
<pre><code class="language-cpp">HandStrengthNames::HandStrengthNamesMapping HandStrengthNames::names = HandStrengthNames::initialize();
</code></pre>
<p>Okay und HandStrengthKey sieht dann noch so aus:</p>
<pre><code class="language-cpp">struct DLL_SPECIFIER /* dllim/export */ HandStrengthKey
{
	HandStrengthDetailType	handStrengthDetail;
	HandStrengthDetailType	exclusiveHandStrengths;
	std::string				customLabel;

	HandStrengthKey(const HandStrengthDetailType&amp; handStrengthDetail, const HandStrengthDetailType&amp; exclusiveHandStrengths)
		: handStrengthDetail(handStrengthDetail), exclusiveHandStrengths(exclusiveHandStrengths) {}

	HandStrengthKey(const HandStrengthDetailType&amp; handStrengthDetail, const HandStrengthDetailType&amp; exclusiveHandStrengths,
		const std::string&amp; customLabel)
		: handStrengthDetail(handStrengthDetail), exclusiveHandStrengths(exclusiveHandStrengths),
	customLabel(customLabel) {}

	bool operator==(const HandStrengthKey&amp; rhs) const;
	bool operator!=(const HandStrengthKey&amp; rhs) const;
	HandStrengthKey&amp; operator|=(const HandStrengthKey&amp; rhs);
	HandStrengthKey&amp; operator&amp;=(const HandStrengthKey&amp; rhs);
	HandStrengthKey operator~() const;
	bool operator&lt;(const HandStrengthKey&amp; rhs) const;
};
</code></pre>
<p>wobei HandStrengthDetailType einfach ein uint64 ist.</p>
<p>Die Fehlermeldung ist mir absolut unbegreiflich und ich schaffe es auch nicht sie zu umgehen:</p>
<blockquote>
<p>1&gt; HandStrengthSelectionDialog.cpp<br />
1&gt;c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(260): error C2678: Binärer Operator '=': Es konnte kein Operator gefunden werden, der einen linksseitigen Operanden vom Typ 'const HandStrengthKey' akzeptiert (oder keine geeignete Konvertierung möglich)<br />
1&gt; c:\users\michael\documents\visual studio 2010\projects\ui\elypsonevaluatorbase\handstrengthkey.h(28): kann 'HandStrengthKey &amp;HandStrengthKey::operator =(const HandStrengthKey &amp;)' sein<br />
1&gt; bei Anpassung der Argumentliste '(const HandStrengthKey, const HandStrengthKey)'<br />
1&gt; c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(259): Bei der Kompilierung der Klassen-template der std::pair&lt;_Ty1,_Ty2&gt; &amp;std::pair&lt;_Ty1,_Ty2&gt;::operator =(std::pair&lt;_Ty1,_Ty2&gt; &amp;&amp;)-Memberfunktion<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Ty1=const HandStrengthKey,<br />
1&gt; _Ty2=std::string<br />
1&gt; ]<br />
1&gt; c:\users\michael\documents\visual studio 2010\projects\ui\...\handstrengthselectiondialog.cpp(113): Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template &quot;std::pair&lt;_Ty1,_Ty2&gt;&quot;.<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Ty1=const HandStrengthKey,<br />
1&gt; _Ty2=std::string<br />
1&gt; ] &lt;-- das ist der Code mit *it</p>
</blockquote>
<p>Die markierte Zeile im untersten Teil der Fehlermeldung ist eben die mit <code>*it</code> . D.h. er versucht irgendwo (?) eine Zuweisung zu machen.</p>
<p>Was ich eigentlich tun will ist eine simple Iteration durch alle map-Elemente. Aber ständig erhalte ich diese dämlichen Fehler, dass die Map ein pair nutzt, dessen first const ist, weswegen die Zuweisung in dieser utility-Funktion nicht klappt.</p>
<p>Irgendwelche Ideen?</p>
<p>Danke im Voraus und beste Grüße!<br />
Eisflamme</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2327110</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2327110</guid><dc:creator><![CDATA[Eisflamme]]></dc:creator><pubDate>Wed, 29 May 2013 14:24:53 GMT</pubDate></item><item><title><![CDATA[Reply to Dereferenzierung von map-Iterator kompiliert nicht on Wed, 29 May 2013 14:20:09 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">const HandStrengthNames::HandStrengthNamesMapping HandStrengthNames::names = HandStrengthNames::initialize();
</code></pre>
<p>Bist du sicher, dass das const da stimmt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2327111</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2327111</guid><dc:creator><![CDATA[sischa]]></dc:creator><pubDate>Wed, 29 May 2013 14:20:09 GMT</pubDate></item><item><title><![CDATA[Reply to Dereferenzierung von map-Iterator kompiliert nicht on Wed, 29 May 2013 14:56:28 GMT]]></title><description><![CDATA[<p>Überbleibsel aus der vorherigen Version, wo ich es noch (was viel logischer ist) const hatte, ändert aber nichts, wenn ich das lösche.<br />
~~<br />
Ich fand jetzt noch raus:<br />
Wenn ich HandStrengthKey rauskopiere in die cpp-Datei und in HandStrengthKey2 umbenenne, das DLL_SPECIFIER dann auch lösche, und eine Map nutze, die HandStrengthKey2 statt HandStrengthKey nutzt, meckert er nicht.</p>
<p>Kann das irgendwie mit dem DLL_SPECIFIER zusammenhängen? Das ist einfach nur ein #define, was sich zu declspec(__dllimport) bzw. declspec(__dllexport) auflöst, einfach um das in die DLL/lib zu exportieren.~~<br />
Na ja, aber wenn ich dann einfach DLL_SPECIFIER aus der eigentlichen Datei lösche, wo HandStrengthKey definiert ist, hilft es nichts, also ist es wohl Blödsinn.</p>
<p>Achso und der operator= von utility will anscheinend irgendwas moven:</p>
<pre><code class="language-cpp">pair&amp; operator=(pair&lt;_Ty1, _Ty2&gt;&amp;&amp; _Right)
		{	// assign from moved pair
		this-&gt;first = _STD move(_Right.first);
		this-&gt;second = _STD move(_Right.second);
		return (*this);
		}
</code></pre>
<p>Auch hier stört er sich an der first-Zeile.</p>
<p>Kann das irgendwie mit der Initialisierungsreihenfolge durch dieses static zu tun haben? Denn wenn ich eine entsprechende Iteration in der cpp-Datei mache, in welcher auch das initialize steht, meckert er nicht.</p>
<p><s>Edit2:<br />
Und wenn ich so eine Iteration nicht in einer freien Funktion sondern in einer Membermethode mache, auch dann ist es kein Problem?!</s> Stimmt so nicht... war in einem Fall zwar korrekt, aber nicht in jedem. Kann ich nicht systematisieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2327114</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2327114</guid><dc:creator><![CDATA[Eisflamme]]></dc:creator><pubDate>Wed, 29 May 2013 14:56:28 GMT</pubDate></item><item><title><![CDATA[Reply to Dereferenzierung von map-Iterator kompiliert nicht on Wed, 29 May 2013 15:16:29 GMT]]></title><description><![CDATA[<p>Kann es sein, daß es <a href="http://support.microsoft.com/default.aspx?scid=KB;EN-US;168958" rel="nofollow">daran</a> scheitert?</p>
<p>Microsoft schrieb:</p>
<blockquote>
<p>How to export an instantiation of [...] a class that contains a data member that is an STL object [...] The only STL container that can currently be exported is vector. [...]</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2327135</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2327135</guid><dc:creator><![CDATA[Caligulaminus]]></dc:creator><pubDate>Wed, 29 May 2013 15:16:29 GMT</pubDate></item><item><title><![CDATA[Reply to Dereferenzierung von map-Iterator kompiliert nicht on Wed, 29 May 2013 16:03:23 GMT]]></title><description><![CDATA[<p>Ich glaube nicht, dass es daran liegt. Der Fehler wird ja auch dann produziert, wenn ich DLL_EXPORT auskommentiere.</p>
<p>Es scheint schon irgendwie mit der Initialisierungsreihenfolge zu tun zu haben. Mein letzter Test war nämlich, dass ich eine Methode/Funktion (egal wie) mit einem Rückgabetyp vector<a href="HandStrengthNamesMapping::value_type" rel="nofollow">HandStrengthNamesMapping::value_type</a> hatte. War der drin, haben alle Iterationen über names den mir unverständlichen Fehler (der vom OP) ausgegeben.</p>
<p>Wenn ich die Funktion/Methode gelöscht habe, verschwanden selbige Fehler jedoch, obwohl das ganz klar Code war, der weder in selbiger Funktion/Methode war noch diese aufgerufen hat, auch nicht indirekt.</p>
<p>Es klappt auch, wenn ich in der ÜE, welche initialize() aufruft, eine Funktion mache, die über alle Map-Elemente iteriert, sie in einen vector&lt;pair&lt;HandStrengthKey, string&gt;&gt; kopiert und diesen zurückgibt. Das ist natürlich absolut umständlich und schafft einen totalen Overhead durch den Kopieraufwand. Aber es klappt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2327151</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2327151</guid><dc:creator><![CDATA[Eisflamme]]></dc:creator><pubDate>Wed, 29 May 2013 16:03:23 GMT</pubDate></item></channel></rss>