Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem – call of <code>std::map::insert</code> member function with invalid parameters: there are two integer values provided; but there <strong>must be</strong> <code>std::pair&lt;int, int&gt;</code>. Please see the reference: <a href="http://en.cppreference.com/w/cpp/container/map/insert" rel="nofollow">std::map::insert</a>.</p> <h1>Preferable option</h1> <p>For <strong>convenience</strong> (just <strong>not to repeat</strong> the map type parameters), create a <code>typedef</code> for the map:</p> <pre><code>typedef std::map&lt;int, int&gt; IntMap; </code></pre> <p>The <code>std::map</code> has type definition for <code>std::pair</code> (pair representation) – <code>std::map::value_type</code>. So, for example, if there is a <code>std::map&lt;int, int&gt;</code> the <code>std::map::value_type</code> would be <code>std::pair&lt;int, int&gt;</code>.</p> <p>Use the <code>std::map::value_type</code> constructor (<code>IntMap::value_type</code> in this case):</p> <pre><code>class Row { public: void Row::addNumber(int num, int pos) { m_numMap.insert(IntMap::value_type(num, pos)); } private: typedef std::map&lt;int, int&gt; IntMap; IntMap m_numMap; }; </code></pre> <h1>Alternatives:</h1> <ol> <li><p>Use <code>std::make_pair()</code> function:</p> <pre><code>#include &lt;utility&gt; ... void Row::addNumber(int num, int pos) { numMap.insert(std::make_pair(num, pos)); } </code></pre></li> <li><p>Directly use <code>std::pair</code> constructor:</p> <pre><code>void Row::addNumber(int num, int pos) { numMap.insert(std::pair&lt;int, int&gt;(num, pos)); } </code></pre></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload