<p>In <a href="https://github.com/mlpack/mlpack/pull/391#discussion_r23553960">src/mlpack/core/optimizers/sdp/lrsdp_function_impl.hpp</a>:</p>
<pre style='color:#555'>&gt; @@ -189,5 +187,40 @@ void AugLagrangianFunction&lt;LRSDPFunction&gt;::Gradient(
&gt;    gradient = 2 * s * coordinates;
&gt;  }
&gt;  
&gt; +// Template specializations for function and gradient evaluation.
&gt; +// Note that C++ does not allow partial specialization of class members,
&gt; +// so we have to go about this in a somewhat round-about way.
&gt; +template &lt;&gt;
&gt; +inline double AugLagrangianFunction&lt;LRSDPFunction&lt;SDP&lt;arma::sp_mat&gt;&gt;&gt;::Evaluate(
&gt; +    const arma::mat&amp; coordinates) const
&gt; +{
&gt; +  return EvaluateImpl(function, coordinates, lambda, sigma);
&gt; +}
</pre>
<p>Hm, right, it actually has to be more complex than this then...</p>

<pre><code>template&lt;typename FunctionType&gt;
inline double AugLagrangianFunction&lt;FunctionType&gt;::Evaluate(
    const arma::mat&amp; coordinates,
    const boost::enable_if&lt;IsLRSDPFunctionType&lt;FunctionType&gt;::result&gt;::result* = 0)
{
  // no more need for EvaluateImpl()
}
</code></pre>

<p>and then</p>

<pre><code>template&lt;typename FunctionType&gt;
struct IsLRSDPFunctionType
{
  static const bool result = false;
};

template&lt;&gt;
struct IsLRSDPFunctionType&lt;LRSDP&lt;SDP&lt;mat&gt;&gt;&gt;
{
  static const bool result = true;
};

template&lt;&gt;
struct IsLRSDPFunctionType&lt;LRSDP&lt;SDP&lt;sp_mat&gt;&gt;&gt;
{
  static const bool result = true;
};
</code></pre>

<p>but at this point the metaprogramming is getting insane enough that maybe your solution is cleaner and easier to read... :)  If there were many more types of <code>SDP&lt;...&gt;</code> I'd suggest it more seriously, but that's not the case...</p>

<p>We wouldn't need to change the type signature on <code>AugLagrangianFunction</code>; we'd need to declare the function above as an extra member.  Anyway, reconsidering the extra complexity of what I just suggested, I'm now against my own idea.  Well, it was fun to think about, at least...</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br>Reply to this email directly or <a href="https://github.com/mlpack/mlpack/pull/391/files#r23553960">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFFf6mKEboPsAgYB4vEy5yqsGKP5bks5nloQkgaJpZM4DVljE.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
  <div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
    <link itemprop="url" href="https://github.com/mlpack/mlpack/pull/391/files#r23553960"></link>
    <meta itemprop="name" content="View Pull Request"></meta>
  </div>
  <meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>