I\'ve seen some examples of C++ using template template parameters (that is templates which take templates as parameters) to do policy-based class design. What other uses do
Here's another practical example from my CUDA Convolutional neural network library. I have the following class template:
template class Tensor
which is actually implements n-dimensional matrices manipulation. There's also a child class template:
template class TensorGPU : public Tensor
which implements the same functionality but in GPU. Both templates can work with all basic types, like float, double, int, etc And I also have a class template (simplified):
template class TT, class T> class CLayerT: public Layer >
{
TT weights;
TT inputs;
TT connection_matrix;
}
The reason here to have template template syntax is because I can declare implementation of the class
class CLayerCuda: public CLayerT
which will have both weights and inputs of type float and on GPU, but connection_matrix will always be int, either on CPU (by specifying TT = Tensor) or on GPU (by specifying TT=TensorGPU).