Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You're converting a <code>map&lt;string,string&gt;</code> to a <code>void**</code>, returning it then converting it back to a <code>map&lt;string,string</code>. Why not just return a <code>map&lt;string,string&gt;</code>? It's also called <code>string2map</code> which implies you will only ever call it with a string (backed up by the fact you pass in a string, which is converted to a <code>void**</code> then converted straight back). Unless you have a good reason to convert to and from <code>void**</code> all over the place this is probably what you need:</p> <pre><code>#include &lt;string&gt; #include &lt;iostream&gt; #include &lt;map&gt; using namespace std; map&lt;string, string&gt; string2map(string st){ map&lt;string, string&gt; result = map &lt;string, string&gt;(); //code doesnt matter return result; } int main(){ string test = "hello:there;how:are you?"; map&lt;string, string&gt; result = string2map(test); return 0; } </code></pre> <p><strong>EDIT:</strong> </p> <p>I've just reread your question. You might want to look up Generalised Functors and look at Boost's <code>std::function</code> as possible solutions to this problem. It's possible to change the return type of a function via a wrapper class, something like:</p> <pre><code>template&lt; class T &gt; class ReturnVoid { public: ReturnVoid( T (*functor)() ) : m_functor( functor ) {} void operator() { Result = functor(); } private: T (*m_functor)(); T Result; }; // Specialise for void since you can't have a member of type 'void' template&lt;&gt; ReturnVoid&lt; void &gt; { public: ReturnVoid( T (*functor)() ) : m_functor( functor ) {} void operator() { functor(); } private: T (*m_functor)(); }; </code></pre> <p>Using this as a wrapper might help you store functors with different return types in the same array.</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.
    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