title: When does a C++ compiler infer noexcept for a method?
body: <p>I just noticing a <code>std::vector&lt;Foo&gt;</code> of mine was copying instead of moving its elements when resizing - even though <code>Foo</code> has a move ctor:</p>
  
  <pre><code>class Foo {
      // ...
      Foo(Foo&amp;&amp; other) : id_(other.id_), ptr_(other.ptr_), flag(other.flag)
      {
          other.flag = false;
      };
      // ...
      int   id_; 
      void* ptr_; 
      bool  flag;
  }
  </code></pre>
  
  <p>Then I read:</p>
  
  <p><a href="https://stackoverflow.com/questions/28166001/resize-on-stdvector-does-not-call-move-constructor">Resize on std::vector does not call move constructor</a></p>
  
  <p>which reminded me that <code>std::vector</code> will only use move construction if the elements' move ctor is declared <code>noexcept</code>. When I add <code>noexcept</code>, move ctor's are called.</p>
  
  <p>My question is: Why, given the move ctor's code, does the compiler not determine it to be <code>noexcept</code>? I mean, it can know for a fact that an exception cannot be thrown. Also, is inferring <code>noexcept</code> disallowed by the standard, or not just done by my specific compiler?</p>
  
  <p>I'm using GCC 5.4.0 on GNU/Linux.</p>