title: does std::function reset its internal function after being moved
body: <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  #include &lt;functional&gt;
  
          template &lt;class F&gt;
          class ScopeExitFunction
          {
          public:
              ScopeExitFunction(F&amp; func) throw() :
                  m_func(func)
              {
              }
  
              ScopeExitFunction(F&amp;&amp; func) throw() :
                  m_func(std::move&lt;F&gt;(func))
              {
              }
  
              ScopeExitFunction(ScopeExitFunction&amp;&amp; other) throw() :
                  m_func(std::move(other.m_func))
              {
               //  other.m_func = []{};
              }
  
              ~ScopeExitFunction() throw()
              {
                  m_func();
              }
  
          private:
              F m_func;
          };
  
  int main() {
      {
          std::function&lt;void()&gt; lambda = [] { cout &lt;&lt; "called" &lt;&lt; endl; };
          ScopeExitFunction&lt;decltype(lambda)&gt; f(lambda);
          ScopeExitFunction&lt;decltype(lambda)&gt; f2(std::move(f));
      }
      return 0;
  }
  </code></pre>
  
  <p>without uncomment this line <code>//  other.m_func = []{};</code>
  the program produce this output :</p>
  
  <blockquote>
    <p>Executing the program.... $demo  called terminate called after
    throwing an instance of 'std::bad_function_call' what():
    bad_function_call</p>
  </blockquote>
  
  <p>is it normal that std::function doesn't reset his internal function when moved ?</p>