Is there a way in C ++ to allow different execution paths for different data types?

I knew that the C ++ template allows functions with different data types to share the same implementation code, but I was wondering if a function has a completely different execution path depends on the data types. Is there any way to do this?

+4
source share
1 answer

For this, you can simply use overloading, in which case you do not need a template.

void path(int value)
{
  //
}

void path(string value)
{
  //
}
+6
source

All Articles