unique_ptr usage - map of class
<p>Can anyone help me with the code below to display the contents of the class object? </p>

<p>Q1 - can anyone confirm - if this is the correct way to store the pointer to table class object in the map?</p>

<p>Q 2 - How to output the contents on the entire record in the map?</p>

<p>Thanks</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;map&gt;
#include &lt;memory&gt;
#include &lt;string&gt;

class Table
{
    public:
    int c1, c2, c3;
    Table() {}

    Table(int _c1,int _c2,int _c3)
    {
      c1=_c1;
      c2=_c2;
      c3=_c3;
    }
};

int main()
{

   std::map&lt;int, std::unique_ptr&lt;Table&gt;&gt; mapTable;
   std::unique_ptr&lt;Table&gt; up(new Table(1,2,3));

   // Is this correct way to store the pointer?
   mapTable.insert(std::make_pair(0,std::move(up)));

   // How can I display c1,c2,c3 values here with this iterator?
   for (const auto &amp;i : mapTable)
    std::cout &lt;&lt; i.first &lt;&lt; " " &lt;&lt; std::endl;

   return 0;
}

// How to get the output in the form - 0,1,2,3 ( 0 map key, 1,2,3 are c1,c2,c3 )
// std::cout &lt;&lt; i.first &lt;&lt; " " &lt;&lt; i.second.get() &lt;&lt; std::endl;  --&gt; incorrect output
</code></pre>
