<?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[STL Map Initialization]]></title><description><![CDATA[<p>Hallo!</p>
<p>weißt jemand wie kann man ein map in Visual C++ initializieren? (ohne die pop/push Funktionen natürlich)</p>
<p>ich habe das hier schon ausprobiert:</p>
<pre><code class="language-cpp">pair&lt;string, int&gt; pa[] =
    {
        pair&lt;string,int&gt;(&quot;one&quot;, 1),
        pair&lt;string,int&gt;(&quot;two&quot;, 2),
        pair&lt;string,int&gt;(&quot;three&quot;, 3),
    };

map&lt;string, int&gt; object(&amp;pa[0], &amp;pa[3]);
</code></pre>
<p>geht wunderbar mit gcc aber sturtz ab mit MSVC. Ideen? Vielen Dank</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/124715/stl-map-initialization</link><generator>RSS for Node</generator><lastBuildDate>Mon, 24 Aug 2026 02:30:59 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/124715.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 30 Oct 2005 19:13:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to STL Map Initialization on Sun, 30 Oct 2005 19:13:00 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>weißt jemand wie kann man ein map in Visual C++ initializieren? (ohne die pop/push Funktionen natürlich)</p>
<p>ich habe das hier schon ausprobiert:</p>
<pre><code class="language-cpp">pair&lt;string, int&gt; pa[] =
    {
        pair&lt;string,int&gt;(&quot;one&quot;, 1),
        pair&lt;string,int&gt;(&quot;two&quot;, 2),
        pair&lt;string,int&gt;(&quot;three&quot;, 3),
    };

map&lt;string, int&gt; object(&amp;pa[0], &amp;pa[3]);
</code></pre>
<p>geht wunderbar mit gcc aber sturtz ab mit MSVC. Ideen? Vielen Dank</p>
]]></description><link>https://www.c-plusplus.net/forum/post/904046</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/904046</guid><dc:creator><![CDATA[--c++]]></dc:creator><pubDate>Sun, 30 Oct 2005 19:13:00 GMT</pubDate></item><item><title><![CDATA[Reply to STL Map Initialization on Mon, 31 Oct 2005 06:03:31 GMT]]></title><description><![CDATA[<p>pa[3] dereferenziert bereits eine Adresse außerhalb des Arrays. Auch wenn Du darauf wieder den Adressoperator anwendest, ist das ungültig. (&amp;pa[0])+3 sollte es aber tun.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/904258</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/904258</guid><dc:creator><![CDATA[7H3 N4C3R]]></dc:creator><pubDate>Mon, 31 Oct 2005 06:03:31 GMT</pubDate></item><item><title><![CDATA[Reply to STL Map Initialization on Mon, 31 Oct 2005 14:01:39 GMT]]></title><description><![CDATA[<p>...oder aber:</p>
<pre><code class="language-cpp">map&lt;string, int&gt; object(pa, pa+3);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/904553</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/904553</guid><dc:creator><![CDATA[HumeSikkins]]></dc:creator><pubDate>Mon, 31 Oct 2005 14:01:39 GMT</pubDate></item><item><title><![CDATA[Reply to STL Map Initialization on Mon, 31 Oct 2005 14:06:26 GMT]]></title><description><![CDATA[<p>HumeSikkins schrieb:</p>
<blockquote>
<p>...oder aber:</p>
<pre><code class="language-cpp">map&lt;string, int&gt; object(pa, pa+3);
</code></pre>
</blockquote>
<p>Warum so einfach...? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/904558</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/904558</guid><dc:creator><![CDATA[7H3 N4C3R]]></dc:creator><pubDate>Mon, 31 Oct 2005 14:06:26 GMT</pubDate></item><item><title><![CDATA[Reply to STL Map Initialization on Mon, 31 Oct 2005 15:34:56 GMT]]></title><description><![CDATA[<p>Es geht nur bei g++. Bei Visual C++ geht es immer noch nicht <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>
<p>Die Fehlermeldung:</p>
<p>:\tmp\c\tests\test1.cpp(13) : error C2664: '__thiscall std::map&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,int,struct std::less&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt;,class std::allocator&lt;int&gt; &gt;::std::map&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,int,struct std::less&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;</p>
<blockquote>
<p>,class std::allocator&lt;int&gt; &gt;(const struct std::less&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt; &amp;,const class std::allocator&lt;int&gt; &amp;)' : Konvertierung des Parameters 1 von 'struct std::pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,int&gt; [3]' in 'const struct std::less&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt; &amp;' nicht moeglich<br />
Ursache: Konvertierung von 'struct std::pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,int&gt; [3]' in 'const struct std::less&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt;' nicht moeglich<br />
Quelltyp konnte von keinem Konstruktor angenommen werden, oder die Ueberladungsaufloesung des Konstruktors ist mehrdeutig</p>
</blockquote>
<p>Und der ganze Code</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;map&gt;

using namespace std;

pair&lt;string, int&gt; pa[] =
    {
        pair&lt;string,int&gt;(&quot;one&quot;, 1),
        pair&lt;string,int&gt;(&quot;two&quot;, 2),
        pair&lt;string,int&gt;(&quot;three&quot;, 3),
    };

map&lt;string, int&gt; object(pa, pa+3); 

main()
{
	cout &lt;&lt; &quot;testchen\n&quot;;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/904673</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/904673</guid><dc:creator><![CDATA[--c++]]></dc:creator><pubDate>Mon, 31 Oct 2005 15:34:56 GMT</pubDate></item><item><title><![CDATA[Reply to STL Map Initialization on Mon, 31 Oct 2005 16:27:54 GMT]]></title><description><![CDATA[<p>Scheinbar hat die Map-Implementierung unterm VC++ keinen Range-Konstruktor oder kennt keine Member-Templates (oder beides). Ist das VC++6? Dann würde ich mir da nix draus machen und das 7er nehmen, falls vorhanden. Anderenfalls musst Du wohl über eine Schleife einfügen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/904746</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/904746</guid><dc:creator><![CDATA[7H3 N4C3R]]></dc:creator><pubDate>Mon, 31 Oct 2005 16:27:54 GMT</pubDate></item></channel></rss>