Iterating through a two dimensional std::unordered_map
<p>I have defined a 2d map as follows:</p>

<pre class="lang-cpp prettyprint-override"><code>unordered_map&lt; string, unordered_map&lt;string, Road*&gt;* &gt; matrix;
</code></pre>

<p>Where road is simply:</p>

<pre class="lang-cpp prettyprint-override"><code>class Road {
public:
    Road() : connected(0), weight(0) {}

    bool connected;
    int weight;
};
</code></pre>

<p>I've tried iterating through the map this way, but it failed to compile.</p>

<pre class="lang-cpp prettyprint-override"><code>    for (auto &amp;i : matrix) {
        for (unordered_map&lt; string, unordered_map&lt;string, Road*&gt;* &gt;::iterator iter1 = i.second-&gt;begin();
             iter1 != i.second-&gt;end(); iter1++) {

        }
    }
</code></pre>

<p>Since I know my matrix is always NxN, one thing I can do is </p>

<pre class="lang-cpp prettyprint-override"><code>    for (auto &amp;i : matrix) {
        for (auto &amp;j : matrix) {

        }
    }
</code></pre>

<p>But i was wondering if there is a cleaner approach with varying size.</p>