title: Passing dynamic allocating object into boost::any constructor
body: <pre><code>#include &lt;iostream&gt;
  #include &lt;boost/any.hpp&gt;
  
  class Str
  {
  public:
    // default constructor
    Str() : str_{"Hello, World!"} { std::cout &lt;&lt; "A::A()" &lt;&lt; this &lt;&lt; std::endl;  }
  
    // copy constructor
    Str(const Str&amp; that) : str_(that.str_) { std::cout &lt;&lt; "A::A(const A&amp;)" &lt;&lt; this &lt;&lt; std::endl; }
    Str(Str&amp; that) : str_(that.str_) { std::cout &lt;&lt; "A::A(A&amp;)" &lt;&lt; this &lt;&lt; std::endl; }
  
    // move constructor
    Str(const Str&amp;&amp; that) : str_(std::move(that.str_)) { std::cout &lt;&lt; "A::A(const A&amp;&amp;)" &lt;&lt; this &lt;&lt; std::endl; }
    Str(Str&amp;&amp; that) : str_(std::move(that.str_)) { std::cout &lt;&lt; "A::A(A&amp;&amp;)" &lt;&lt; this &lt;&lt; std::endl; }
    // destructor
    ~Str() { std::cout &lt;&lt; "~A::A()" &lt;&lt; this &lt;&lt; std::endl; }
  
    // str print method
    void print() const { std::cout &lt;&lt; str_ &lt;&lt; '\n'; }
  
  private:
    std::string str_;
  };
  
  int main(int argc, char *argv[])
  {
    auto* str = new Str;
    boost::any a(*str);
    if (a.empty()) {
      std::cout &lt;&lt; "empty\n";
    } else {
      std::cout &lt;&lt; "not empty\n";
    }
    auto s = boost::any_cast&lt;Str&gt;(&amp;a);
    std::cout &lt;&lt; s &lt;&lt; std::endl;
    std::cout &lt;&lt; a.empty() &lt;&lt; std::endl;
    delete str;
    return 0;
  }
  </code></pre>
  
  <p>This simple program have output:</p>
  
  <pre><code>A::A()0x24f5c20
  not empty
  0
  0
  ~A::A()0x24f5c20
  </code></pre>
  
  <p>And so, to understand it right, the correct program output need to be:</p>
  
  <pre><code>A::A()0x24f5c20
  A::A(const A&amp;)some address // copy str before passing into any constructor
  not empty 
  some address 
  0 
  ~A::A()some address //~any() call ~A()some address
  ~A::A()0x24f5c20
  </code></pre>
  
  <p>It looks like don't understand what is going on.
  That was compiled with g++ version 5.4.0. 
  People! What is wrong with me? =)</p>