title: Using std::map<K,V> where V has no usable default constructor
body: <p>I have a symbol table implemented as a <code>std::map</code>. For the value, there is no way to legitimately construct an instance of the value type via a default constructor. However if I don't provide a default constructor, I get a compiler error and if I make the constructor assert, my program compile just fine but crashes inside of <code>map&lt;K,V&gt;::operator []</code> if I try to use it to add a new member.</p>
  
  <p><em>Is there a way I can get C++ to disallow <code>map[k]</code> as an l-value at compile time (while allowing it as an r-value)?</em></p>
  
  <hr>
  
  <p>BTW: I know I can insert into the map using <code>Map.insert(map&lt;K,V&gt;::value_type(k,v))</code>.</p>
  
  <hr>
  
  <p><strong>Edit:</strong> several people have proposed solution that amount to altering the type of the value so that the map can construct one without calling the default constructor. <strong>This has exactly the opposite result of what I want</strong> because it hides the error until later. If I were willing to have that, I could simply remove the assert from the constructor. What I <em>Want</em> is to make the error happen even sooner; at compile time. However, it seems that there is no way to distinguish between r-value and l-value uses of <code>operator[]</code> so it seems what I want can't be done so I'll just have to dispense with using it all together.</p>