title: Is there any way to limit the size of an STL Map?
body: <p>I want to implement some sort of lookup table in C++ that will act as a cache.  It is meant to emulate a piece of hardware I'm simulating.</p>
  
  <p>The keys are non-integer, so I'm guessing a hash is in order. I have no intention of inventing the wheel so I intend to use <code>std::map</code> for this (though suggestions for alternatives are welcome).</p>
  
  <p>The question is, is there any way to limit the <em>size</em> of the hash to emulate the fact that my hardware is of finite size?  I'd expect the hash's <em>insert</em> method to return an error message or throw an exception if the limit is reached.</p>
  
  <p>If there is no such way, I'll simply check its size before trying to insert, but that seems like an inelegant way to do it.</p>