I have a Templated class. by default I use this class with different types (float, double, integer etc.). Now I wan't to give that class different implementations (one for single core execution and 1 for multithreading).
This is not possible in C++ to have virtual template methods. So some possible solutions are
1) write a different interface for every type and then write 2 implementation for each interface. (this requires of adding new methods for exchanging values between the two classes)
2) just add a branch to very method in the old implementation
Code: Select all
//so:
T getValue()
{
if(multythreadin)
{
//new code
return Value; //of type T
}
//old code
return Value;
}
http://www.java2s.com/Tutorial/Cpp/0260 ... mplate.htm