<p>A common pattern with STL containers is this:</p>

<pre><code>map&lt;Key, Value&gt; map;
for(map&lt;Key, Value&gt;::iterator iter = map.begin(); iter != map.end(); ++iter)
{
  ...
}
</code></pre>

<p>So in order to avoid writing the declaration of the template parameters we can do this somewhere:</p>

<pre><code>typedef map&lt;Key, Value&gt; TNiceNameForAMap;
</code></pre>

<p>But if this map is only used in a single function or for a single iteration this is an annoying overhead.</p>

<p>Is there any way around this typedef?</p>

Not sure what you mean by "overhead". If it simplifies the way you write your code, use it, otherwise stick with the longhand.
If it's only used in a restricted scope, put the typedef in that same scope. Then it doesn't need to be published, or documented, or appear on any UML diagrams. For example (and I don't claim this is the best code ever in other respects):
```
```
int totalSize() {
    typedef std::map<Key, Value> DeDuplicator;
    DeDuplicator everything;

    // Run around the universe finding everything. If we encounter a key
    // more than once it's only added once.

    // now compute the total
    int total = 0;
    for(DeDuplicator::iterator i = everything.begin(); i <= everything.end(); ++i) {
        total += i->second.size(); // yeah, yeah, overflow. Whatever.
    }
    return total;
}
```
```
Combining with Ferruccio's suggestion (if you're using boost), the loop becomes:
```
```
BOOST_FOREACH(DeDuplicator::pair p, everything) {
    total += p.second.size();
}
```
```
And combining with bk1e's suggestion (if you're using C++0x or have features from it), and assuming that BOOST_FOREACH interacts with auto in the way I think it should based on the fact that it can normally handle implicit casts to compatible types:
```
```
std::map<Key, Value> everything;
// snipped code to run around...
int total = 0;
BOOST_FOREACH(auto p, everything) {
    total += p.second.size();
}
```
```
Not bad.