You could use typeid
:
if (typeid(T) == typeid(int))
Or you could use the std::is_same
type trait:
if (std::is_same<T, int>::value)
More Related Contents:
- C++ template typedef
- initializer_list and move semantics
- Derived template-class access to base-class member-data
- How to convert a lambda to an std::function using templates
- C++ template constructor
- static_assert fails compilation even though template function is called nowhere
- How to force a static member to be initialized?
- How can I declare a member vector of the same class?
- C++ preprocessor: avoid code repetition of member variable list
- “not declared in this scope” error with templates and inheritance [duplicate]
- Uses of a C++ Arithmetic Promotion Header
- check if member exists using enable_if
- Why can’t templates be within extern “C” blocks?
- Variadic deduction guide not taken by g++, taken by clang++ – who is correct?
- Best introduction to C++ template metaprogramming? [closed]
- C++ type registration at compile time trick
- C++ overloaded function as template argument
- When instantiating a template, should members of its incomplete argument types be visible?
- C++ template, linking error [duplicate]
- How do we declare a friend function with a class template into .h file and define them into a .cpp file (not all in one header file)?
- Making a C++ class a Monitor (in the concurrent sense)
- Why the initializer of std::function has to be CopyConstructible?
- Interfacing C++11 array with Cython
- c++ standard practice: virtual interface classes vs. templates
- Template definitions outside class body
- Partial specialization of function templates
- C++ templates declare in .h, define in .hpp
- Why does stack not compile in g++? [duplicate]
- Optimize template replacement of a switch
- Dynamic dispatching of template functions?