Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>operator std::map&lt;T, U&gt;() { return m_map; } </code></pre> <p>This is user-defined <em>conversion</em> function.</p> <p>That means, you can write this:</p> <pre><code>//obj is an object of type create_map create_map&lt;int,std::string&gt; obj(1,"Nawaz"); //obj implicitly converts into std::map type! std::map&lt;int,std::string&gt; map_inst=obj; </code></pre> <hr> <p>See this topic to know more about <strong>user-defined conversion function</strong>:</p> <p><a href="https://stackoverflow.com/questions/3008690/user-defined-conversions-in-c">User Defined Conversions in C++</a></p> <p>You can see this as well: <a href="http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=/com.ibm.xlcpp8a.doc/language/ref/implicit_conversion_sequences.htm" rel="nofollow noreferrer">Implicit conversion sequences (C++ only)</a></p> <hr> <pre><code>create_map&lt;T, U&gt;&amp; operator()(const T&amp; key, const U&amp; val) { m_map[key] = val; return *this; } </code></pre> <p>This actually overloads the <code>operator()</code>, which internally inserts or updates (key,val) pair into the <code>m_map</code>; just see the function definition as to what it does. </p> <p>So using this function you can write code like this,</p> <pre><code>obj(2,"Sarfaraz"); //this inserts the pair into the underlying m_map; </code></pre> <p>I would also suggest you to explore <code>std::map</code> a bit more, especially the overloaded <code>operator[]</code> in <code>std::map</code>.</p>
    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