Here is a simple code in C++:
#include
#include
template
void function()
{
std::cout << typeid(T).n
For c++ the term 'static polymorphism' is normally used for e.g. the CRTP type design patterns:
template
class Base
{
void someFunc() {
static_cast(this)->someOtherFunc();
};
};
class ADerived : public Base
{
void someOtherFunc() {
// ...
}
};
It generally means that types and inheritance constraints are deduced and verified at compile/link time. The compiler will emit error messages if operations are missing or invalid on the specified types. In that sense it's not really polymorphism.