C++ - Copy Assignment Operator is Implicitly Deleted
<p>I'm trying to use copy assignment in the following case.</p>

<p>There're two template classes, <code>list map</code> and <code>xpair</code>.</p>

<pre><code>template &lt;typename Key, typename Value, class Less=xless&lt;Key&gt;&gt;
class listmap {
public:
   using key_type = Key;
   using mapped_type = Value;
   using value_type = xpair&lt;const key_type, mapped_type&gt;;     //value_type
...
}

template &lt;typename First, typename Second&gt;
struct xpair {
   First first{};
   Second second{};
   xpair(){}
   xpair (const First&amp; first, const Second&amp; second):
           first(first), second(second) {}
};
</code></pre>

<p>In the main.cpp, I tried to write,</p>

<pre><code>using commend = string;
using str_str_map = listmap&lt;string,string&gt;;
using str_str_pair = str_str_map::value_type;    //value_type, to be replaced
using commend_pair = xpair&lt;commend, str_str_pair&gt;;

int main(...) {
   commend_pair cmd_pair;
   str_str_pair newPair ("Key", "value");
   cmd_pair.second = newPair;

   ...
}
</code></pre>

<p>It gives me an error saying </p>

<pre><code>  object of type 'xpair&lt;const std::__1::basic_string&lt;char&gt;,
  std::__1::basic_string&lt;char&gt; &gt;' cannot be assigned because its copy
  assignment operator is implicitly deleted
</code></pre>

<p>If I replace </p>

<pre><code>using str_str_pair = str_str_map::value_type;
</code></pre>

<p>to</p>

<pre><code>using str_str_pair = xpair&lt;string, string&gt;;
</code></pre>

<p>Everything works fine. Why is that? Shouldn't <code>value_type = xpair&lt;string, string&gt;</code>? </p>