Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I understand your question that you want map: <code>key-&gt;map&lt;key,&gt;::iterator</code></p> <p>So, here it is, a struct with map iterator as value:</p> <pre><code>template &lt; template &lt;class K, class V, class C, class A&gt; class mapImpl, class K, class V, class C=std::less&lt;K&gt;, class A=std::allocator&lt;std::pair&lt;const K, V&gt; &gt; &gt; class value_with_iterator { public: typedef typename mapImpl&lt;const K,value_with_iterator,C,A&gt;::iterator value_type; value_type value; }; </code></pre> <p>Map defined with using struct above: </p> <pre><code>typedef std::map&lt;size_t, value_with_iterator &lt;std::map, size_t, size_t&gt; &gt; map_size_t_to_itself; </code></pre> <p>Some insert method - to link key with itself:</p> <pre><code>map_size_t_to_itself::iterator insert(map_size_t_to_itself&amp; mapRef, size_t value) { map_size_t_to_itself::value_type v(value, map_size_t_to_itself::mapped_type()); std::pair&lt;map_size_t_to_itself::iterator, bool&gt; res = mapRef.insert(v); if (res.second) res.first-&gt;second.value = res.first; return res.first; } </code></pre> <p>And simple test:</p> <pre><code>int main() { map_size_t_to_itself mapObj; map_size_t_to_itself::iterator i1 = insert(mapObj, 1); map_size_t_to_itself::iterator i2 = insert(mapObj, 1); map_size_t_to_itself::iterator i3 = insert(mapObj, 2); std::cout &lt;&lt; i1-&gt;first &lt;&lt; ": " &lt;&lt; i1-&gt;second.value-&gt;first &lt;&lt; std::endl; std::cout &lt;&lt; i2-&gt;first &lt;&lt; ": " &lt;&lt; i2-&gt;second.value-&gt;first &lt;&lt; std::endl; std::cout &lt;&lt; i3-&gt;first &lt;&lt; ": " &lt;&lt; i3-&gt;second.value-&gt;first &lt;&lt; std::endl; } </code></pre> <p>with OUTPUT:</p> <pre><code>1: 1 1: 1 2: 2 </code></pre> <p>Full link: <a href="http://ideone.com/gnEhw" rel="noreferrer">http://ideone.com/gnEhw</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload