compile time check template type C++ <p>I am trying to check a template type and appropriate invoke a function. However, this doesn't seem to work. I tried with is_same, <a href="http://stackoverflow.com/questions/14094214/c-compile-time-type-checking">C++ compile-time type checking</a>, <a href="http://stackoverflow.com/questions/16924168/compile-time-function-for-checking-type-equality">compile-time function for checking type equality</a> and the boost::is_same. Everything is giving me the same error. The following is a sample code.</p> <pre><code>#include &lt;iostream&gt; #include &lt;type_traits&gt; using namespace std; class Numeric { public : bool isNumeric() { return true; } }; class String { }; template &lt;class T&gt; class Myclass { private: T temp; public: void checkNumeric() { if(std::is_same&lt;T,Numeric&gt;::value) { cout &lt;&lt; "is numeric = " &lt;&lt; temp.isNumeric(); } else { cout &lt;&lt; "is numeric = false" &lt;&lt; endl; } } }; int main() { Myclass&lt;Numeric&gt; a; a.checkNumeric(); Myclass&lt;String&gt; b; b.checkNumeric(); } </code></pre> <p>While compiling the above code, I am getting the following error.</p> <pre><code>make all Building file: ../src/TestCPP.cpp Invoking: GCC C++ Compiler g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/TestCPP.d" -MT"src/TestCPP.d" -o "src/TestCPP.o" "../src/TestCPP.cpp" ../src/TestCPP.cpp:36:36: error: no member named 'isNumeric' in 'String' cout &lt;&lt; "is numeric = " &lt;&lt; temp.isNumeric(); ~~~~ ^ ../src/TestCPP.cpp:51:4: note: in instantiation of member function 'Myclass&lt;String&gt;::checkNumeric' requested here b.checkNumeric(); ^ 1 error generated. make: *** [src/TestCPP.o] Error 1 </code></pre> <p>In this case, I neither have String or Numeric class. It comes out of a third party library. I implement only MyClass which will be packaged as another library. I expect the application that uses MyClass will either pass me a String or Numeric which belongs to a third party class. MyClass is a specialized matrix operation and Dense/Sparse matrix are the Numeric and String like classes that comes from a third party library. I want to check if the application that uses my library and the third party library is invoking MyClass based on the class type that belongs to the third party library. </p> <p>Kindly let me know how to fix this problem. </p>