title: How to use insert_or_assign in map for custom class?
body: <p>I am using insert_or_assign of c++17 <a href="https://en.cppreference.com/w/cpp/container/map/insert_or_assign" rel="nofollow noreferrer">https://en.cppreference.com/w/cpp/container/map/insert_or_assign</a>
  this says that the mapped value is constructed using rvalue reference i.e. std::move.</p>
  <p>Here is my custom class, which I am using as a key. Next is the value, which I am using as vector.
  While I am trying to use uniform initialization, I get the compilation error. Also, if I use std::pair still I get an error.
  I am unable to understand what that error really means? Here is the error and the code.</p>
  <p>Without std::pair</p>
  <pre><code>g++ -std=c++17 map.cpp -o map.out
  map.cpp: In function ‘int main(int, char**)’:
  map.cpp:51:66: error: no matching function for call to ‘std::map&lt;MyData, std::vector&lt;std::__cxx11::basic_string&lt;char&gt; &gt; &gt;::insert_or_assign(&lt;brace-enclosed initializer list&gt;, &lt;brace-enclosed initializer list&gt;)’
     51 |    studentClasses.insert_or_assign( {36, &quot;Naja&quot;s}, {&quot;class 5th&quot;s});
  </code></pre>
  <p>With std::pair,  I get the following -</p>
  <pre><code>map.cpp:42:76: error: no matching function for call to ‘make_pair(&lt;brace-enclosed initializer list&gt;, &lt;brace-enclosed initializer list&gt;)’
     42 |    studentClasses.insert_or_assign( std::make_pair({36, &quot;Naja&quot;}, {&quot;year 5&quot;}));
        |     
  
                                                                     ^
  </code></pre>
  <p>Now, here is the entire code ,</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;map&gt;
  #include &lt;vector&gt;
  
  using namespace std;
  
  class MyData
  {
      private:
          int age;
        string name;
     public:
        int getAge()
        {
           return age;
        }
        string&amp; getName()
        {
          return name; 
        }
        MyData(int age_val, string name_val): age(age_val), name(name_val) 
        {
           cout&lt;&lt;&quot;Constructor invoked&quot;&lt;&lt;endl;
        }
        bool operator &lt;(const MyData &amp;other) const
        {
           return age &lt; other.age;
        }
  };
  
  int main(int argc, char **argv)
  {
     std::map&lt;MyData, vector&lt;string&gt;&gt; studentClasses;
     studentClasses.insert_or_assign( std::make_pair({36, &quot;Naja&quot;}, {&quot;year 5&quot;})); 
     //studentClasses.insert_or_assign( {36, &quot;Naja&quot;s}, {&quot;class 5th&quot;s}); 
     return 0;
  }
  </code></pre>