There's not a simple way to do this directly. From the solidity docs:
The mapping or the dynamic array itself occupies an (unfilled) slot in storage at some position p according to the above rule (or by recursively applying this rule for mappings to mappings or arrays of arrays). For a dynamic array, this slot stores the number of elements in the array (byte arrays and strings are an exception here, see below). For a mapping, the slot is unused (but it is needed so that two equal mappings after each other will use a different hash distribution). Array data is located at keccak256(p) and the value corresponding to a mapping key k is located at keccak256(k . p) where . is concatenation. If the value is again a non-elementary type, the positions are found by adding an offset of keccak256(k . p).
That is, mappings do not contain pointers to values. Mappings are ways to turn arbitrary key into pointers to values. For two different mapping keys to point to the same location in memory, and therefore share an value, would be astronomically unlikely.
But there is a workaround.
Let map1
and map2
be mappings of addresses to uints. Then, use either a dynamic array of someStructs or a mapping of uints to someStructs. Store the actual structs in this latter array or mapping. Use the uints of map1
and map2
as a kind of homemade pointer to said structs. This should not use all that much more gas in the end.