title: C++ template specialization problem
body: <p>I need a C++ template that, given a type and an object of that type, it can make a decision based on whether the type is an integer or not, while being able to access the actual objects. I tried this</p>
  
  <pre><code>template &lt;typename T, T &amp;N&gt;
  struct C {
      enum { Value = 0 };
  };
  
  template &lt;int &amp;N&gt;
  struct C&lt;int, N&gt; {
      enum { Value = N };
  };
  </code></pre>
  
  <p>but it doesn't work. Is there any way I can achieve something similar?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>What I was trying to achieve was something like this, that would happen at compile time:</p>
  
  <pre><code>if (type is int) {
      return IntWrapper&lt;int_value&gt;
  else {
      return type
  }
  </code></pre>
  
  <p>You can actually pass pointers or references to objects in a template instantiation, like so:</p>
  
  <pre><code>struct X {
      static const int Value = 5;
  };
  
  template &lt;X *x&gt;
  struct C {
      static const int Value = (*x).Value; 
  };
  
  X x;
  
  std::cout &lt;&lt; C&lt;&amp;x&gt;::Value &lt;&lt; std::endl; // prints 5
  </code></pre>
  
  <p>but apparently all this accomplishes is to initialize the template by inferring <code>x</code>'s type, and <code>x</code> also needs to be declared globally. No use for what I'm trying to do, which I think is not possible after all at compile time.</p>