title: RAII std::vector design conundrum
body: <p>I’m not a fan of classes like the one below that have an IsValid() function, because you have to remember to check IsValid() everywhere:</p>
  
  <pre><code>struct BadTextWidget
  {
      BadTextWidget(const std::string &amp; TEXT) : m_text(TEXT) {}
      bool IsValid() const;
      ...
  </code></pre>
  
  <p>I prefer the RAII approach which makes it impossible to construct an invalid object:</p>
  
  <pre><code>struct BetterTextWidget
  {
      BetterTextWidget(const std::string &amp; TEXT) : m_text(TEXT)
      {
          if (IsValid(m_text) == false) throw std::invalid_argument("...");
      }
      ...
  </code></pre>
  
  <p>However, I also like using vectors, but that requires constructor arguments to have default values which are not going to be valid.  This forces me to use BadTextWidget again.</p>
  
  <p>So how do you get the performance characteristics of std::vector with validating constructors that throw?  How do you resolve this design conundrum?  What am I missing?</p>