title: What should be the exception guarantee in a (default) constructor that throws?
body: <p>I know that constructors can throw exceptions and this can be a good thing to do when something bad happens. But when the constructor throws, and assuming that all resources inside constructor are properly managed (for example using <a href="http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization" rel="nofollow">RAII</a>), which one is the exact exception guarantee (basic, strong)?</p>
  
  <p>In detail, I'm documenting my code and writing the exception guarantees of every member function (and trying of write safe-exception code).</p>
  
  <p>For example, if I have a class like this:</p>
  
  <pre><code>struct A
  {
      std::string s;
  
      A()
      {
          std::vector&lt;int&gt; v(5);
          s = "some text";
  
          /* do a lot of fascinating things */
  
          if (error)
              throw 1;
      }
  };
  </code></pre>
  
  <p>When the constructor throws, destructor of <code>v</code> and <code>s</code> are called, right? So, thanks to destructors of <code>std::vector</code> and <code>std::string</code> the constructor of <code>A</code> doesn't leak any resources and then it offers at least the basic guarantee. Am I right?</p>
  
  <p><strong>My question is: Can I say that this constructor offers the strong guarantee?</strong>
  Also, is it worth to document the guarantee of constructors?</p>
  
  <p>My guess: it has the strong guarantee indeed. Since the object didn't exist before trying to construct it, and if constructor fails the object won't be created anyway, then the operation (construct the object) has no effect and everything is left just before the constructor started.</p>
  
  <p>If my guess is right:</p>
  
  <ul>
  <li>when a constructor just offers the basic guarantee and not the strong guarantee?</li>
  </ul>