title: externally defined function pointer as template argument
body: <p>Consider following code:</p>
  
  <p>main.cpp:</p>
  
  <pre><code>#include &lt;iostream&gt;
  typedef void ( * fncptr)(void);
  extern void externalfunc(void);
  
  template&lt;void( * test)(void)&gt;
  class Bar
  {
  public:
      Bar() { test(); }
  };
  
  void localfunc()
  {
      std::cout &lt;&lt; "Hello World" &lt;&lt; std::endl;
  }
  constexpr fncptr alias = localfunc;
  extern fncptr externalAlias;
  int main(int argc, char* argv[])
  {
      Bar&lt;localfunc&gt; b;
      Bar&lt;alias&gt; b2; // This wouldn't compile if alias wasn't constexpr
      Bar&lt;externalfunc&gt; b3;
  //  Bar&lt;externalAlias&gt; b4;
  
      return 0;
  }
  </code></pre>
  
  <p>and external.cpp:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  typedef void ( * fncptr)(void);
  
  void externalfunc()
  {
      std::cout &lt;&lt; "Hello external world" &lt;&lt; std::endl;
  }
  
  fncptr externalAlias = externalfunc;
  </code></pre>
  
  <p>Now the problem is I need something like the 4th line in the main func to work. I get those function declarations from an external C library so I cannot touch those. Currently the 4th line does not compile. gcc 4.6 says "it must be the address of a function with external linkage". In fact it does also say this if you make <code>alias</code> not constexpr, so the actual meaning (I think) should be interpreted as: "I don't know for 100% sure the function address you're giving me is constant which I need for instantiating this template". Is there any way around this as i cannot declare <code>externalalias</code> as <code>constexpr</code> in <code>main.cpp</code>?</p>
  
  <p>Before you come with alternate solutions: I am already trying to get this work by just passing the function pointers through the constructor and save them locally but I am still interested if I could get make the template version to work :).</p>