Smart pointers and map in C++
<p>I'm trying to execute this program with smart pointers:</p>

<pre><code>//File user.h
#include &lt;list&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;fstream&gt;
#include &lt;sstream&gt;
#include &lt;memory&gt;
#include &lt;map&gt;

using namespace std;

class User {
    string name;
    int id;
public:
    User(const string&amp; name, int id) : name(name), id(id) {}
    int getID() const {return id;}
    ~User(){}
};

//File main.c
#include "user.h"
using namespace std;
typedef std::shared_ptr&lt;User&gt; UserPtr;
typedef map&lt;string, UserPtr&gt; Dict;

int main()
{
    Dict dict;
    dict = new User("Adams", 666);
    auto it = dict.find("Adams");

    if (it == dict.end())
        cout &lt;&lt; "not found!" &lt;&lt; endl;

    else
        cout &lt;&lt; "id3: " &lt;&lt; it-&gt;second-&gt;getID() &lt;&lt; endl;

    return 0;
}
</code></pre>

<p>I have tested it before with raw pointers (*) and it works. Nonetheless, when using smart pointers I get the following errors:</p>

<pre><code>main.cpp: In function ‘int main()’:
main.cpp:15:10: error: no match for ‘operator=’ (operand types are ‘Dict {aka std::map&lt;std::basic_string&lt;char&gt;, std::shared_ptr&lt;User&gt; &gt;}’ and ‘User*’)
     dict = new User("Adams", 666);
          ^
main.cpp:15:10: note: candidates are:
In file included from /usr/include/c++/4.8/map:61:0,
                 from user.h:10,
                 from main.cpp:3:
/usr/include/c++/4.8/bits/stl_map.h:264:7: note: std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;&amp; std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;::operator=(const std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;&amp;) [with _Key = std::basic_string&lt;char&gt;; _Tp = std::shared_ptr&lt;User&gt;; _Compare = std::less&lt;std::basic_string&lt;char&gt; &gt;; _Alloc = std::allocator&lt;std::pair&lt;const std::basic_string&lt;char&gt;, std::shared_ptr&lt;User&gt; &gt; &gt;]
       operator=(const map&amp; __x)
       ^
/usr/include/c++/4.8/bits/stl_map.h:264:7: note:   no known conversion for argument 1 from ‘User*’ to ‘const std::map&lt;std::basic_string&lt;char&gt;, std::shared_ptr&lt;User&gt; &gt;&amp;’
/usr/include/c++/4.8/bits/stl_map.h:279:7: note: std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;&amp; std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;::operator=(std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;&amp;&amp;) [with _Key = std::basic_string&lt;char&gt;; _Tp = std::shared_ptr&lt;User&gt;; _Compare = std::less&lt;std::basic_string&lt;char&gt; &gt;; _Alloc = std::allocator&lt;std::pair&lt;const std::basic_string&lt;char&gt;, std::shared_ptr&lt;User&gt; &gt; &gt;]
       operator=(map&amp;&amp; __x)
       ^
/usr/include/c++/4.8/bits/stl_map.h:279:7: note:   no known conversion for argument 1 from ‘User*’ to ‘std::map&lt;std::basic_string&lt;char&gt;, std::shared_ptr&lt;User&gt; &gt;&amp;&amp;’
/usr/include/c++/4.8/bits/stl_map.h:300:7: note: std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;&amp; std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;::operator=(std::initializer_list&lt;std::pair&lt;const _Key, _Tp&gt; &gt;) [with _Key = std::basic_string&lt;char&gt;; _Tp = std::shared_ptr&lt;User&gt;; _Compare = std::less&lt;std::basic_string&lt;char&gt; &gt;; _Alloc = std::allocator&lt;std::pair&lt;const std::basic_string&lt;char&gt;, std::shared_ptr&lt;User&gt; &gt; &gt;]
       operator=(initializer_list&lt;value_type&gt; __l)
       ^
/usr/include/c++/4.8/bits/stl_map.h:300:7: note:   no known conversion for argument 1 from ‘User*’ to ‘std::initializer_list&lt;std::pair&lt;const std::basic_string&lt;char&gt;, std::shared_ptr&lt;User&gt; &gt; &gt;’
</code></pre>

<p>Is the smart pointer wrongly declared?</p>