title: Lazy initialization of unique_ptr in C++11
body: <p>I'm developing c++ project in c++11 (gcc 4.8.2). Recently I found <code>unique_ptr</code> is useful for me. Unfortunately I can't use the <code>std::make_unique</code> function in my environment. So I tried lazy initialization of <code>unique_ptr</code> by using <code>std::move</code>.</p>
  
  <p>Actually, the below code works, I don't have confidence in myself. Could you give any comments on better ways to initialize a <code>unique_ptr</code>? I think my initialization is a little redundant.</p>
  
  <pre><code> class AppData {
       public:
           AppData(int id):_id(id){};
  
           int _id;
           void print() { std::cout &lt;&lt; "id is " &lt;&lt; _id &lt;&lt; std::endl; };
   };
  
   class Test {
       public:
           Test(){};
           ~Test(){};
           void test();
  
           std::unique_ptr&lt;AppData&gt; p_data;
   };
  
   void Test::test() {
       // I am concerned with this part
       std::unique_ptr&lt;AppData&gt; p(new AppData(3));
       p_data = std::move(p);
       p_data-&gt;print();
   }
  
   int main() {
       Test t;
       t.test();
  
       return 0;
   }
  </code></pre>