title: C# to C++11 conversion: delegate templates
body: <p>I'm trying to convert this C# code to C++:</p>
  
  <pre><code>public delegate void Action&lt;in T&gt;(T obj);
  public delegate void Action&lt;in T1, in T2&gt;(T1 arg1, T2 arg2);
  public delegate void Action&lt;in T1, in T2, in T3&gt;(T1 arg1, T2 arg2, T3 arg3);
  </code></pre>
  
  <p>Pretty clear this calls for std::function. Since this is a larger project I used a tool to do all the conversion and this is what it came up with:</p>
  
  <pre><code>#include &lt;functional&gt;
  
      template&lt;typename T&gt;
  //C# TO C++ CONVERTER TODO TASK: C++ does not allow specifying covariance or contravariance in a generic type list:
  //ORIGINAL LINE: public delegate void System::Action&lt;in T&gt;(T obj);
      using std::function&lt;void()&gt; = std::function&lt;void (T obj)&gt;;
  
      template&lt;typename T1, typename T2&gt;
  //C# TO C++ CONVERTER TODO TASK: C++ does not allow specifying covariance or contravariance in a generic type list:
  //ORIGINAL LINE: public delegate void System::Action&lt;in T1, in T2&gt;(T1 arg1, T2 arg2);
      using std::function&lt;void()&gt; = std::function&lt;void (T1 arg1, T2 arg2)&gt;;
  
      template&lt;typename T1, typename T2, typename T3&gt;
  //C# TO C++ CONVERTER TODO TASK: C++ does not allow specifying covariance or contravariance in a generic type list:
  //ORIGINAL LINE: public delegate void System::Action&lt;in T1, in T2, in T3&gt;(T1 arg1, T2 arg2, T3 arg3);
      using std::function&lt;void()&gt; = std::function&lt;void (T1 arg1, T2 arg2, T3 arg3)&gt;;
  </code></pre>
  
  <p>I assumed using <code>std::function&lt;void()&gt;</code> is a translation error, so I changed them to <code>Action</code>. So, my final version is this:</p>
  
  <pre><code>template&lt;typename T&gt;
  using Action = std::function&lt;void(T obj)&gt;;
  
  template&lt;typename T1, typename T2&gt;
  using Action = std::function&lt;void(T1 arg1, T2 arg2)&gt;;
  
  template&lt;typename T1, typename T2, typename T3&gt;
  using Action = std::function&lt;void(T1 arg1, T2 arg2, T3 arg3)&gt;;
  </code></pre>
  
  <p>But this doesn't compile, with the understandable error that Action is already defined (when reaching the second using line). However, there's the possibility to have template functions with overloads (same name, different template parameters), so I wonder why this doesn't work for my alias templates. Is it simply not supported or do I miss something?</p>
  
  <p>Also, maybe I did not fully understand co- and contravariance, but in my opinion they do not apply to this problem (no type inheritance involved here), so I don't see what the converter tool wants to tell me by these comments.</p>