Deduce first template parameter in multiple parameter template by parameter
<p>First my question and then an explanation of what I'm trying to do as I might be approaching the problem wrong.</p>

<p>Is it possible to deduce the first template parameter in a multi parameter template from parameters while specifying the other parameters.</p>

<p>Example: </p>

<pre><code> template&lt;class A, class B&gt;
 B function(A object)
 { 
     return B(A);
 }
</code></pre>

<p>called like:</p>

<pre><code> function&lt;BType&gt;(AInstance);
</code></pre>

<p>I could not find a way to make this work.</p>

<p>EDIT: Another example might fit better to my problem below as indicated to me by the first comment I got</p>

<p>Example: </p>

<pre><code> template&lt;class A, A::B foo&gt;
 void function(A object)
 { 
     object.doSomethingWithTypeA::B(foo);
 }
</code></pre>

<p>called like:</p>

<pre><code> function&lt;A::BInstance&gt;(AInstance);
</code></pre>

<p>The difference is that the second template parameter is dependent on the specific type of the first so I can not switch the template parameters around.</p>

<p>Now for a description of what I am trying to do:</p>

<p>I am currently trying to create a templates universal functor class that can take either a free function or a member function and wrap it into a functor. </p>

<p>I succeeded in what I set out to do but now I want to make everything just a bit more user friendly. Currently the templated function to create a functor looks like:</p>

<pre><code>template &lt;class T, ReturnType (T::*Method)(FunctionArguments...)&gt;
static constexpr UniversalFunctor Create(T* object) {
   return {object, MethodWrapper&lt;T, Method&gt;};
}
</code></pre>

<p>Right now to create a functor for a member function a user has to call</p>

<pre><code>UniversalFunctor&lt;ReturnType&gt;::Create&lt;ClassName, ClassFunction&gt;(Object)
</code></pre>

<p>which is rather cumbersome.</p>

<p>Since Object has to be of type ClassName or at least be deducible to this I would have expected that a call like:</p>

<pre><code>UniversalFunctor&lt;ReturnType&gt;::Create&lt;ClassFunction&gt;(Object)
</code></pre>

<p>should also be able to succeed as the ClassName parameter is deducible from the pointer passed. However that does not appear to be possible as ClassFunction is always treated as the first template parameter.</p>