title: Creating a SWIG typemap for C++ overloaded functions
body: <p>I would like to know how to create a SWIG typemap for overloaded functions.</p>
  
  <p><strong>MyBindings.h</strong></p>
  
  <pre><code>static void test(t_string *s)
  {
      std::cout &lt;&lt; "first : " &lt;&lt; s-&gt;name &lt;&lt; '\n');
  }
  
  static void test(t_string *s, t_string *s2)
  {
      std::cout &lt;&lt; "first : " &lt;&lt; s-&gt;name &lt;&lt; '\n');
      std::cout &lt;&lt; "second : " &lt;&lt; s2-&gt;name &lt;&lt; '\n');
  }
  </code></pre>
  
  <p><strong>MyBindings.i</strong></p>
  
  <pre><code>%module my
  %{
      #include "MyBindings.h"
  %}
  
  %include &lt;stl.i&gt;
  %include &lt;exception.i&gt;
  %include &lt;typemaps.i&gt;
  /* convert the input lua_String to t_string* */
  %typemap(in) t_string*
  {
      if (!lua_isstring(L, $input))
          SWIG_exception(SWIG_RuntimeError, "argument mismatch: string expected");
      $1 = makestring(lua_tostring(L, $input));
  }
  </code></pre>
  
  <p>And if I call <code>test()</code> in Lua,</p>
  
  <pre><code>my.test("abc", "def");
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>Wrong arguments for overloaded function 'test'
    Possible C/C++ prototypes are:
      test(t_string *)
      test(t_string *,t_string *)
  </code></pre>
  
  <p>How should I correct my typemap to make it work?</p>