Large matrix with lots of repetitive fields (C++)
Why have nested unordered_maps. Just use a single unordreed map using a key that is the x and y coordinates?

One enhancement I would add is using the operator[][] to access the elements.

#include &lt;unordered_map&gt;
#include &lt;utility&gt;
#include &lt;iostream&gt;
#include &lt;functional&gt;


template &lt;typename T&gt;
class UMapMatrix
{
    public:

        UMapMatrix(T const&amp; default_val = T())
            : default_val(default_val)
        {   
        }   

        T const&amp; get(int a, int b) const
        {   
            auto key    = getKey(a, b); 
            auto search = data.find(key);
            return (search != data.end())
                       ? search-&gt;second;
                       : default_val;
        }   

        void set(int a, int b, T const&amp; val)
        {   
            data.insert(std::make_pair(getKey(a,b), val));
        }   
        void set(int a, int b, T&amp;&amp; val)
        {   
            data.insert(std::make_pair(getKey(a,b), std::move(val)));
        }

        class Row 
        {   
            UMapMatrix const* parent;
            int a;

            public:
            Row(UMapMatrix const* parent, int a)
                : parent(parent)
                , a(a)
            {}  
            T const&amp; operator[](int b) const
            {   
                return parent-&gt;get(a, b); 
            }   
        };  
        Row operator[](int a) const {
            return Row{this, a}; 
        }   


    private:
        T default_val;
        using Key = std::pair&lt;int, int&gt;;
        struct PairHash
        {   
            std::size_t operator()(Key const&amp; key) const
            {   
                return std::hash&lt;int&gt;()(key.first) ^ std::hash&lt;int&gt;()(key.second);
            }   
        };  


        Key getKey(int a, int b) const {

            int x = std::min(a, b); 
            int y = std::max(a, b); 
            return std::make_pair(x, y); 
        }   

        std::unordered_map&lt;Key, T, PairHash&gt;  data;
};

int main()
{
    UMapMatrix&lt;int&gt;     data;

    std::cout &lt;&lt; data.get(1500, 3000) &lt;&lt; "\n";
    data.set(1500, 3000, 234);

    std::cout &lt;&lt; data[1500][3000] &lt;&lt; "\n";
}