title: template specialization for static member functions; howto?
body: <p>I am trying to implement a template function with handles void differently using template specialization.</p>
  
  <p>The following code gives me an "Explicit specialization in non-namespace scope" in gcc:</p>
  
  <pre><code>template &lt;typename T&gt;
  static T safeGuiCall(boost::function&lt;T ()&gt; _f)
  {
      if (_f.empty())
          throw GuiException("Function pointer empty");
      {
          ThreadGuard g;
          T ret = _f();
          return ret;
      }
  }
  
  // template specialization for functions wit no return value
  template &lt;&gt;
  static void safeGuiCall&lt;void&gt;(boost::function&lt;void ()&gt; _f)
  {
      if (_f.empty())
          throw GuiException("Function pointer empty");
      {
          ThreadGuard g;
          _f();
      }
  }
  </code></pre>
  
  <p>I have tried moving it out of the class (the class is not templated) and into the namespace but then I get the error "Explicit specialization cannot have a storage class". I have read many discussions about this, but people don't seem to agree how to specialize function templates. Any ideas?</p>